I'm trying to write a program that reads an integer from the user (through the keyboard), adds 100 to it and displays the result. All I can do is get them to concatenate like 2 strings, instead of adding the numbers together. I can't understand why it won't add them.
import java.io.*;
public class Program {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.print("Enter some text: ");
String text = br.readLine();
int number = Integer.parseInt(text);
System.out.println(" Your value + 100 is " + ( 100 + text));
}
}
is the code I am using and:
Enter some text: 66
Your value + 100 is 10066
is what is printed on the screen.
100 + number.