Question: / * Starter project for Assignment 1 3 File I / O for Grade Average Your job is to write a program to read the

/* Starter project for Assignment 13 File I/O for Grade Average
Your job is to write a program to read the grades.txt file
in this project, to produce output like shown here.
"grades.txt" is the file your program should read. "badformat.txt" is an example of a file that your program can't read, so a clear error message should be generated, as shown in the sample output.
*/
import java.io.*;
import java.util.Scanner;
class Main
{
private static final int NUM_SCORES =4;
// named constant for the number of scores per student in file
public static void main(String[] args)
{
}
}
/****** Sample Output on Repl, hills, or other Linux
(specifying an invalid path will throw an exception): *****
Remember that "cat" is a Linux command to display the
contents of a text file on the screen.
Welcome to the Grade Average Calculator.
Please enter the name of a file to input:
trash
Unable to open file: trash
Please enter the name of a file to input:
grades.txt
Enter name of output file to create:
trash/trash
Unable to open file: trash/trash
Enter name of output file to create:
gradeAvg.txt
Average grades saved to gradeAvg.txt
> cat grades.txt
Biden 85909598
Trump 50707580
Obama 90959897
Bush 80707585
Clinton 90958599
Bush 85959094
> cat gradeAvg.txt
Here are the average grades:
Biden 92.0
Trump 68.8
Obama 95.0
Bush 77.5
Clinton 92.3
Bush 91.0
> java Main
Welcome to the Grade Average Calculator.
Please enter the name of a file to input:
badformat.txt
Enter name of output file to create:
gradeAvg.txt
The file badformat.txt isn't in the right format:
it should have 1 name followed by 4 numbers on each line,
separated by spaces. The following error was generated:
4 scores should follow each name, with spaces in between.
Grades could not be averaged.
> cat badformat.txt
Biden 8590
Trump 507075
Obama 90959897
Bush 80707585
Clinton 90958599Bush 85959094
*/
badformat.txt - Biden 8590
Trump 507075
Obama 90959897
Bush 80707585
Clinton 90958599Bush 85959094
grades.txt - Biden 85909598
Trump 50707580
Obama 90959897
Bush 80707585
Clinton 90958599
Bush 85959094
 /* Starter project for Assignment 13 File I/O for Grade Average

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!