002-003-009

Converting String to Integer

Easy

Problem Description

Converting String to Integer

In this problem, you will create a program that reads a string representing an integer from standard input, uses Integer.parseInt() to convert it to an integer, adds 8 to it, and displays the result to standard output.

Learning Objective: Understand how to convert strings to integers using Integer.parseInt()

Overview

Convert a number represented as a string to an integer and perform calculations.

Specifications

  • Read one line from standard input representing an integer as a string
  • Convert to integer using Integer.parseInt()
  • Add 8 to the converted value
  • Output the result

Input Format

numeric string

Output Format

Original: <original value>
After adding 8: <result>

Input/Output Example

Input: 42
Output:
Original: 42
After adding 8: 50

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up