Without the parentheses the second "+" would mean "string concatenation," not addition.
Here is an input file for use with this program.
The file is named input.txt
.
12 7
Here is a sample run of the program with this data file:
C:\users\default\JavaLessons>java AddTwo < input.txt Enter first number: Enter second number: Sum: 19 C:\users\default\JavaLessons>
Warning: The input file for this program cannot contain any characters that are not part of an integer. The characters must be an optional leading + or - followed by digit characters '0' through '9'. This includes spaces in front of a number. The following input file will not work:
12 7