Your task is to read a file containing exam scores and to wr
Your task is to read a file containing exam scores, and to write another file that contains the results of processing the exam scores. The output file should number and list each score that was read in, show the total number of scores that were read, and show the average score. The output format should contain these lines:
Complete the following code:
Solution
ExamAverage.java
import java.io.File;
 import java.io.FileReader;
 import java.io.FileNotFoundException;
 import java.util.Scanner;
 import java.io.PrintWriter;
public class ExamAverage
 {
   
 public static void main(String[] args)
 throws FileNotFoundException
 {
 String inputFileName = \"D:\\\\scores.txt\";
 String outputFileName = \"D:\\\\examScoreAverage.txt\";
// TODO: Open the input and output files.
 File input = new File(inputFileName);
 File output = new File(outputFileName);
 Scanner scan = new Scanner(input);
 PrintWriter pw = new PrintWriter(output);
 int count = 0;
 double sum = 0;
 // Read records from the input file.
 while(scan.hasNextDouble()){
    count++;
    double d = scan.nextDouble();
    sum = sum + d;
    pw.write(\"Score \"+count+\": \"+d);
    pw.write(\"\ \");
 }
 pw.write(\"Number of scores read: \"+count);
pw.write(\"\ \");
 double average = sum/count;
 // Calculate the average score.
 pw.write(\"Average Score: \"+average);
 pw.flush();
 pw.close();
 scan.close();
 // Write each exam score, the count of scores read,
 // and the average score to the output file.
   
 System.out.println(\"File has been created\");
 }
 }
Output:
File has been created
examScoreAverage.txt
Score 1: 90.0
 Score 2: 80.0
 Score 3: 92.0
 Score 4: 83.0
 Score 5: 74.0
 Score 6: 93.0
 Score 7: 79.0
 Score 8: 89.0
 Score 9: 84.0
 Score 10: 91.0
 Number of scores read: 10
 Average Score: 85.5


