Java program to create a final grade calculator Requirements
Java program to create a final grade calculator.
Requirements:
I. The system shall ingest student_grades_input.txt (see next page). This comma delimited input text file
contains the names and grades of 30 students. Each student has grades for six assignments: 3
Homework Assignments, 1 Midterm, 1 Project, and 1 Final.
II. The system shall compute the final numerical grade for each student using the following:
final_numerical_grade = 0.45*[(HW1+HW2+HW3)/3] + 0.25*Project + 0.30*[(Midterm+Final)/2]
III. The system shall use the following to determine the final letter grade:
Final Numerical Grade Final Letter Grade
90 - 100 A
80 - 89 B
70 - 79 C
60 - 69 D
0 - 59 F
IV. The system shall use a GUI to display the final letter grade for each student. Note, a scroll bar may be
needed to fit all the names and grades within the GUI. Please be sure to include screenshots that detail
the entire output. More than one screenshot may be required.
V. At the bottom of the GUI, include the total number of A\'s, B\'s, C\'s, D\'s, and F\'s.
student_grades_input.txt
Name,HW1,HW2,HW3,Midterm,Project,Final
Stephen Curry,100,100,95,100,85,98
Michael Jordan,100,100,100,100,90,90
Kobe Bryant,95,90,98,91,87,92
Kevin Durant,92,98,94,94,88,94
Russell Westbrook,90,90,93,90,80,93
Lebron James,98,100,97,98,89,91
Klay Thompson,90,89,94,91,88,95
Chris Paul,94,85,100,94,85,94
Reggie Miller,100,94,95,96,94,91
Tim Duncan,90,91,97,98,89,91
Tony Parker,97,95,96,92,88,94
Steve Nash,100,80,90,94,96,96
Karl Malone,89,70,86,96,85,80
Scottie Pippen,88,75,70,90,94,96
Allen Iverson,85,80,69,91,75,86
Tim Hardaway,100,0,75,65,95,89
Kevin Garnett,89,56,91,88,79,73
Kyrie Irving,75,64,89,70,90,82
Vince Carter,91,89,76,64,0,70
Tracy McGrady,88,76,54,61,91,79
Larry Bird,0,86,100,96,84,88
Magic Johnson,87,80,70,66,77,91
Chris Mullin,99,87,94,0,86,84
John Stockton,89,91,96,88,85,80
David Robinson,65,56,88,46,77,90
Charles Barkley,78,60,89,79,35,0
Derrick Rose,94,78,90,86,80,88
Dwayne Wade,90,56,86,70,62,30
Carmelo Anthony,60,0,50,84,46,92
Ray Allen,97,64,95,75,88,89
Solution
data.java
public class data
{
private String name;
private int hw1,hw2,hw3,midterm,project,fin;
public data(String name, int hw1,int hw2,int hw3,int midterm,int project,int fin)
{
this.name = name;
this.hw1 = hw1;
this.hw2 = hw2;
this.hw3 = hw3;
this.midterm = midterm;
this.project = project;
this.fin = fin;
}
public char grade()
{
double total=0,t1=0,t2=0,t3=0;
t1=0.45*((hw1+hw2+hw3)/3);
t2=0.25*project;
t3=0.30*((midterm+fin)/2);
total=t1 + t2 + t3;
char g=\' \';
if(total>90 && total<100)
g=\'A\';
if(total>80 && total<89)
g=\'B\';
if(total>70 && total<79)
g=\'C\';
if(total>60 && total<69)
g=\'D\';
if(total>0 && total<59)
g=\'E\';
return g;
}
public String toString()
{
return \"name: \" + name;
}
}
temp.java
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class temp
{
public static void main( String [] args )
{
// create ArrayList to store the invetory objects
List<data> student = new ArrayList<>();
try
{
// create a Buffered Reader object instance with a FileReader
BufferedReader br = new BufferedReader(new FileReader(\"temp.txt\"));
// read the first line from the text file
String fileRead = br.readLine();
//skip first line of file
fileRead = br.readLine();
// loop until all lines are read
while (fileRead != null)
{
// use string.split to load a string array with the values from each line of
// the file, using a comma as the delimiter
String[] tokenize = fileRead.split(\",\");
// assume file is made correctly
// and make temporary variables for the three types of data
String name = tokenize[0];
int hw1 = Integer.parseInt(tokenize[1]);
int hw2 = Integer.parseInt(tokenize[2]);
int hw3 = Integer.parseInt(tokenize[3]);
int midterm = Integer.parseInt(tokenize[4]);
int project = Integer.parseInt(tokenize[5]);
int fin = Integer.parseInt(tokenize[6]);
// creat temporary instance of data object
// and load with three data values
data tempObj = new data(name,hw1,hw2,hw3,midterm,project,fin);
// add to array list
student.add(tempObj);
// read next line before looping
// if end of file reached
fileRead = br.readLine();
}
// close file stream
br.close();
}
// handle exceptions
catch (FileNotFoundException fnfe)
{
System.out.println(\"file not found\");
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
// display data
for (data each : student)
{
System.out.println(\"====================\");
System.out.print(each);
//System.out.println();
System.out.printf(\" grade is = %c %n\", each.grade());
}
}
}
temp.txt:
Name,HW1,HW2,HW3,Midterm,Project,Final
Stephen Curry,100,100,95,100,85,98
Michael Jordan,100,100,100,100,90,90
Kobe Bryant,95,90,98,91,87,92
Kevin Durant,92,98,94,94,88,94
Russell Westbrook,90,90,93,90,80,93
Lebron James,98,100,97,98,89,91
Klay Thompson,90,89,94,91,88,95
Chris Paul,94,85,100,94,85,94
Reggie Miller,100,94,95,96,94,91
Tim Duncan,90,91,97,98,89,91
Tony Parker,97,95,96,92,88,94
Steve Nash,100,80,90,94,96,96
Karl Malone,89,70,86,96,85,80
Scottie Pippen,88,75,70,90,94,96
Allen Iverson,85,80,69,91,75,86
Tim Hardaway,100,0,75,65,95,89
Kevin Garnett,89,56,91,88,79,73
Kyrie Irving,75,64,89,70,90,82
Vince Carter,91,89,76,64,0,70
Tracy McGrady,88,76,54,61,91,79
Larry Bird,0,86,100,96,84,88
Magic Johnson,87,80,70,66,77,91
Chris Mullin,99,87,94,0,86,84
John Stockton,89,91,96,88,85,80
David Robinson,65,56,88,46,77,90
Charles Barkley,78,60,89,79,35,0
Derrick Rose,94,78,90,86,80,88
Dwayne Wade,90,56,86,70,62,30
Carmelo Anthony,60,0,50,84,46,92
Ray Allen,97,64,95,75,88,89




