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

3. Gradebook Program a. (StudentData.java) Write the definition of the class Stu

ID: 3662534 • Letter: 3

Question

3. Gradebook Program a. (StudentData.java) Write the definition of the class StudentData such that an object of this class can store a student’s id, first name, last name, midterm score, final score, and homework score. - Include 6 private data members: id, firstName, lastName, midtermScore, finalScaore, and hwScore. - Add constructors, getters and setters. - Add a method that calculates and returns the average score. o The method signature should be • public double calculateAverageScore() o Average score = midtermScore * 30% + finalScore * 40% + hwScore * 30% - Add a method that determines and returns the grade. o The method signature should be • public char calculateGrade() o A – the average score is 90 and above; o B – the average score is 80 to 89; o C – the average score is 70 to 79; o D – the average score is 60 to 69; o F – the average is 59 and below. - Override the toString method so that it returns student data as a string. b. (GradeBook.java) Write a menu-driven client program that can help the instructor to manage the grade book. The program should repeatedly execute until the user choose not to. - Use an array of objects of the class StudentData to store each student’s data. - Read the data file “student_data.txt” to populate the array of objects (the data file is on D2L). - Use a menu to do the following. 1: Output students’ information. 2: Output the class average. 3: Find the student with the highest score and display his/her information. 4: Find the students with the final grade A and display his/her information. 0: End the program.

Explanation / Answer

import java.io.*; import java.util.*; public class StudentData{ private int id; private String firstName; private String lastName; private double averageScore; public StudentData() //default constructor { } public StudentData(int id, String firstName, String lastName, double averageScore) { this.id = id; this.firstName = firstName; this.lastName = lastName; this.averageScore = averageScore; } public void setId( int id ) { this.id = id; } public int getId() { return id; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getFirstName() { return firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getLastName() { return lastName; } public void setAverageScore(double averageScore) { this.averageScore = averageScore; } public double getAverageScore() { return averageScore; } public char calculateGrade() { char grade; if(this.averageScore >=90){ grade = 'A'; } else if(this.averageScore >=80){ grade = 'B'; } else if(this.averageScore >= 70){ grade = 'C'; } else if(this.averageScore >= 60){ grade = 'D'; } else{ grade = 'F'; } return grade; } public String toString() { return "id = " + id + "," + "name = " + name + "," + "avarege score = " + averageScore + "," + "grade is" + calculateGrade(); } } //GradeBook.java import java.io.*; import java.util.*; public class GradeBook //client program { public static void main(String[] args) throws FileNotFoundException { //create an array of 10 elements of type StudentData??? StudentData[] students = new Student[10]; //create and associate the Scanner object to the input file??? Scanner sc = new Scanner("student_data.txt"); //create ten StudentData object to populate the array ??? //read data from the file and set each object properly ??? StringTokenizer st = null; for(int 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