help with program named TestAverages.java that asks the user for…

Question help with program named TestAverages.java that asks the user for… Image transcription textJuan Fulano: 88, 82, 89 Tran Thi B: 91, 87.5, 92, 89, 88.5 Jan Kovacs: 91, 93, 8r, 74.5 Joseph Schmegeggie:Erika Mustermann: 79.5, 83.5, 90, 92 Here is the result of running the program several times. First, with a badinput file name: Enter input file name with test scores: nosuchfile. txt Cannot find input file nosuch… Show more… Show more help with program named TestAverages.java that asks the user for the name of an input file that has people’s names and test scores. Each line has the person’s name, a colon, and a list of scores separated by commas.Next, the program asks the user for the name of an output file. The program will then read the input file and write a new output file with the names and their average scores, including the number of tests on which it is based.Error HandlingIf the input file does not exist or cannot be opened, print an appropriate error message.If the output file cannot be opened, print an appropriate error message.If an input line has a non-numeric entry for a score, print an error message to the screen with the bad data and skip that score.If an input line has no scores, print an appropriate message to the screen.Why my output is empty /** that asks the user for the name of an input file* that has people’s names and test scores.* Each line has the person’s name, a colon, and a list of scores*  separated by commas.* The program will then read the input file*  and write a new output file with the names and*  their average scores,*  including the number of tests on which it is based*/public class TestAverages {// named constant for the number of scores per student in filepublic static void main(String[] args) {Scanner scanner = new Scanner(System.in);Scanner input;PrintWriter writer;String inputFilename;String outputFilename;File outputFile;String outputString = “”;while (true) {System.out.println(“Please enter the name of a file to input:”);inputFilename = scanner.nextLine();File file = new File(inputFilename);try {input = new Scanner(file);break;} catch (FileNotFoundException e) {System.out.println(“Unable to open file: ” + inputFilename);}}while (true) {System.out.println(“Enter name of output file to create:”);outputFilename = scanner.nextLine();outputFile = new File(outputFilename);try {writer = new PrintWriter(outputFile);break;} catch (Exception e) {System.out.println(“IO Error:” + outputFilename + ” (Permission denied)”);}}while (input.hasNextLine()) {String line = input.nextLine();int count = 0;String[] grade = line.split(“, “);count += grade.length;if (grade.length < 10) {System.out.println("Tgnoring bad number  8r for Jan Kovacsn"+ "No numbers found on line Joseph Schmegeggiere is: ");System.out.println("File" + outputFilename + " written successfully.");scanner.close();input.close();try {writer.close();} catch (Exception e) {System.out.println("An error occurred while closing the file writer.");}System.exit(0);}double sum = 0.0;for (int i = 1; i <= grade.length; i++) {sum += Double.parseDouble(grade[i]);}double average = sum / count;outputString += grade[0] + ", " + String.format("%.1f", average) + "n";throw new NumberFormatException("Ignoring non-numeric data ");}writer.write(outputString);writer.close();System.out.println("Average grades saved to " + outputFilename);System.out.println("An error occurred while writing to the output file.");input.close();writer.close();scanner.close();}      Engineering & Technology Computer Science CS 12 Share QuestionEmailCopy link Comments (0)