User input numbers not adding together

后端 未结 3 1432
轻奢々
轻奢々 2021-01-27 02:46

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

3条回答
  •  死守一世寂寞
    2021-01-27 03:28

    int number = Integer.parseInt(text) + 100;
    
     System.out.println(" Your value + 100 is " + ( number));
    

    or

    System.out.println(" Your value + 100 is " + ( 100 + number));
    

    For a string "+" works to concatenate , i.e append the string together :)

提交回复
热议问题