Question
a program that calculates the final course grade by reading student grades from a text file. Design a class MyGrade with the following instance variables
a program that calculates the final course grade by reading student grades from a text file. Design a class MyGrade with the following instance variables holds the sum of all homework grades homeworkSum homeworkCount holds the total number of homework grades labsum holds the sum of all lab grades labCount holds the total number of lab grades o labReportSum holds the sum of all lab reports labReportCount holds the total number of lab report grades holds the score for Exam 1 examl O exam2 holds the score for Exam 2 holds the score for the final exam finalExam Create a default constructor for MyGrade and set the values of all instance variables to 0 . Create the following methods: getHomeworkAverage(returns the average of homework grades getLabAverage)returns the average of lab grades getLabReportAverage()returns the average of lab report grades o getExam1) returns the Exam-1 grade getExam2) returns the Exam-2 grade getFinalExam)returns the Final Exam grade addGrade) takes in 2 parameters and returns nothing, a String for the category of assignment (homework/lab/exam etc.) and a grade. The addGrade() method keeps track of the grade count per assignment category and the sum of all grades per assignment category. For example: If the assignment category is either a lab/lab report/homework, then the O value is added to the corresponding sum and the count is increased by 1 for that category If the assignment category is either Exam-1/Exam-2/Final Exam, then the value is assigned to the corresponding instance variable. getFinalNumberGrade() computes the final number grade based on the weights as follows: Final Number Grade (Lab Average 0.10) (Lab Report Average 0.10) (Homework Average 0.20) +(1st highest exam score * 0.30) (2nd highest exam score 0.30) This method returns the final number grade rounded to the next integer (Hint: use Math.ceil() o getCourseLetterGrade)takes in the final number grade and returns the course letter grade using the table below: Course Letter Grade Range 90 100 A B+ 86 89 80 85 C+ 76-79 C 70 75 66 69 D+ D 60 65 F 0 59 readGradesFile()takes in the file name and reads the grades in that file O The file format is as follows: n In In In In In In In The assignment category can either be LABS, LAB REPORTS, HOMEWORK, EXAM 1 EXAM 2 or FINAL Each category and grade are separated using the end line character "In" Labs, Lab Reports, and Homework have multiple grades which need to be averaged. Also, the number of grades for these categories cannot be assumed. Exam 1, Exam 2 and the Final exam only have one grade. The assignment categories may appear in any order See the sample text file provided (Grades.txt) writeOutput()displays the homework average, lab average, lab report average, exam-1 grade, exam-2 grade, final exam grade and also the Final Number grade and the Course Letter grade. Create another class, Grade Calculator This class prompts the user to enter a fille name O creates an object of the MyGrade class reads the student grades from the file provided computes all values and prints the results on the console. Sample Output: Enter the file name containing student grades: Grades.txt Lab Average: 94.0 Lab Report Average: 97.8 Homework Average: 80.3 Exam 1: 84.3 Exam 2: 87.5 Final Exam: 85.0 Final Number Grade: 87.0 Course Letter Grade: B+ Submission: Compress all .java files Upload the compressed folder to Blackboard
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the implementation of the MyGrade class java import javautilScanner import javaioFile import javaioFileNotFoundException public class MyGrade pr...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started