Input The attached files: inputl.txt, input2.txt, input3.txt, input4.txt are the
ID: 2246383 • Letter: I
Question
Input The attached files: inputl.txt, input2.txt, input3.txt, input4.txt are the test cases that will be used as input for your program (Right-click and save): Output The attached files: outputl.txt, output2.txt, output3.txt, output4.xt are the expected outputs of the corresponding input files from the previous section (Right-click and save): Important Note: If you are downloading these files to a machine with Windows OS, an extra blank line will be added at the end of each file. However that line does not exist in the CSE205 server, so when you use these files to test your program, please delete or ignore the last blank line. If you make your program to produce an extra blank line at the end of output, your program will not pass the test cases when submitting to the system. In this assignment, each output file should contain exactly 4 lines. b. This program uses the Scanner class. The Scanner class simplifies the way programs read input.Explanation / Answer
import java.util.Scanner;
public class Assignment1
{
public static void main(String[] args)
{
int number;
Scanner console = new Scanner(System.in);
number = console.nextInt();
//display the number with other messages
System.out.print("This program reads an integer from a keyboard, "
+ "and prints it out on the display screen. "
+ "Make sure that you get the exact same output as the expected one. "
+ "The read number is " + number + ". ");
}
}
The program has been corrected to give the exact input matching the expected output. First there is a space before "and" in the second line in the given program (that has been corrected) and also in the last line there is a ":" which is not there in the expected output file so that also has been removed to match the output. The third line has "make" but it should be "Make" as per the expected output.