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.
Each number must contain only the digits
0
through 9
.
Negative numbers can start with -
,
but positive number cannot start with a plus.
The number can be separated by spaces and can be preceeded by
spaces or blank lines.
This input file will work:
12 -7
As will this:
12 -7
But not this:
12 +7
What is wrong with the second input file?