Write a program in Java The program reads a text file with student records (firs
ID: 3657789 • Letter: W
Question
Write a program in Java The program reads a text file with student records (first name, last name and grade) and prints them in the terminal window. After the name and grade it also prints the type of the grade: excellent (> 89), ok [60,89], and failure (< 60). Then the program prints the number of students, and their average grade and also the number of students and their average in each grade category (excellent, ok, and failure). For example, with the input file students.txt the program must print the following: John Smith 90 excellent Barack Obama 95 excellent Al Clark 80 ok Sue Taylor 55 failure Ann Miller 75 ok George Bush 58 failure John Miller 65 ok There are 7 students with average grade 74.0 There are 2 excellent students with average grade 92.5 There are 3 ok students with average grade 73.3333 There are 2 failre students with average grade 56.5 Requirements: Use the scanner class for reading from file. Use the Student.java class from the course website to represent each student record and extend it to handle the grade categories. Print the student records (name, grade and grade category) using the println method with only a student object passed to it (hint: modify the toString method in class Student to return also the grade category). When you write your program use proper names for the variables suggesting their purpose. format your code accordingly using indentation and spacing. for each line of code add a short comment to explain its meaning.Explanation / Answer
import java.until.*;
import java.io.*;
public class Assign7{
public static void main(String[] args)throws Exception{
Record.setGP(1.25, 1.25, 0.25, 0.50);
Scanner myIn = new Scanner( new File("scores.txt") );
public static void main getLetterGrade
if (finalScore > 90)
letter = 'A';
else if (finalScore > 80)
letter = 'B';
else if (finalScore > 70)
letter = 'C';
else if (finalScore > 60)
letter = 'D';
else
letter = 'F';
System.out.println( myIn.nextLine() +" avg "+"letter");
while( myIn.hasNext() ){
Record myR = new Record(myIn.next(), myIn.nextInt(), myIn.nextInt(), myIn.nextInt(),
myIn.nextInt());
System.out.println( myR );
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.