Answer:

The user will see something like:

C:\java AddUpFile < largeData.txt
Enter a number:
Enter a number:
Enter a number:
Enter a number:
Enter a number:
Enter a number:

.... and so on 100 times

Grand Total: 1688

The one hundred useless prompts will be quite irritating.

Useless Prompts

Often programs that do input from a file do not write prompts. But when you are first writing the program it is good to include them so you can more easily debug the program. Once the program is debugged, change the line that prints the prompt:

//System.out.println("Enter a number:");

If you need the prompt in again, it is simple to remove the slashes.

It would greatly enhance your development as a World-class hacker to copy this program to Notepad and hack upon it. You will need a data file of 100 integers. This is easy to do. In a text editor, enter 10 lines of numbers, something like:

1
2
3
4
5
-1
-2
-3
-4
-5

Now use the copy and paste commands to make 9 duplicates of these ten lines. You will have 100 lines of integers which should sum to zero. Save the file under some convenient name, such as zeroData.txt. Use it with your program.

QUESTION 12:

What will happen with the program if there is less data in the file than the program needs?