|
|
This is an exercise in file I/O and exception handling: Write a program that requests a file name from the user. Data for this exercise is in CS1337Asg5Data.txt. If the file name the user enters is not found, loop until they enter either an asterisk or a correct file name. If they enter an asterisk, the progarm should quit. Data is in the form of name/number pairs. The program should do the following: 1. Read each line of the file. If the second data element (the one after the comma) is not a valid floating-point number, skip the line and record that it contained an error. If it is valid, add it to a running sum. 2. Print the running sum of the numbers on each valid line, the average, and the total number of valid lines. This should be printed at the end; you need not print every line. 3. Print the name, value, (the contents of the input line) and line number for each line which contains an invalid value. 4. Print the total number of lines containing errors. Take a look at the data file, but do not make any changes to your copy of it, before starting on this. |
|
To hand in: Submit your Java source code (.java file(s) on e_learning. Your files should be named <Last Name>Asg5. For example, if I were submitting it, I would use the name ColeAsg5. Grades and comments will be posted online. Your program must have the following in the comments at the top of the first page:
NOTE: LATE HOMEWORK WILL NOT BE ACCEPTED AND WILL BE RECORDED AS A ZERO. GET AN EARLY START. |