Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that reads the exam scores from a file. You are towrite a separa

ID: 3609607 • Letter: W

Question

Write a program that reads the exam scores from a file. You are towrite a separate program namedGradesFromFile.java. This program will prompt theuser for the name of the file, and then your program will read allthe values from the file
For example, the data file could be:
9887868578737264727293706650
NOTICE that there is no -1 value at the end of the file!Now when you run your program, an example of the output is shownbelow:
 Welcome to the Grade Calculator ProgramPlease enter the name of the data file to process: scores.txtGrade Calculations:Total number of grades = 14High score = 98Low score = 50Average score = 76.14Number of A's = 2Number of B's = 3Number of C's = 6Number of D's = 2Number of F's = 1

Specifications

Your program must meet the following specifications:
  • The name of the source code file must be exactlyGradesFromFile.java (Name it exactly -capital/lower case letters are important! )
  • Comments at the top with your name, e-Name, date andcourse.
  • Must use a Scanner object to read user input. However, yourprogram may only create one Scanner object.
  • Note blank line before "Grade Calculations:".
  • You must print the average score up to two decimal points. Ifit comes out to exactly an integer value, then have it add .0 tothe end. For example, if the average is 72, then print "72.0". Ifthe average is 72.1824333 then print "72.18".

Explanation / Answer

import java.util.*;import java.io.*;class GradesFromFile {public static void main(String[] args) {int []score = new int[100];double avg,sum=0;int count=-1;int i;String name;File file = null;int gradeA=0,gradeB=0,gradeC=0,gradeD=0,gradeF=0;Scanner key = new Scanner(System.in);System.out.println("Enter the file name:");name = key.nextLine();Scanner scanner = null;file = new File (name);try {// Create a scanner to read the filescanner = new Scanner (file);} catch (FileNotFoundException e) {System.out.println ("File not found!");// Stop program if no file foundSystem.exit (0);}System.out.println("Enter score:");do{ if (!scanner.hasNext ()) break;count++;}while((score[count] = scanner.nextInt()) >=0);for(i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote