Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(1) In GradeBook2revised class, modify the constructor so that it has three parameters: the course name, the number of students, and the number of exams.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

(1) In GradeBook2revised class, modify the constructor so that it has three parameters: the course name, the number of students, and the number of exams. Define number of students and the number of exams as int type of variables. And then in the constructor to build an appropriately sized two- dimensional array by using those parameters. And then set each element of the new two-dimensional array to-1 to indicate that no grade has been entered for that element in the contructor. (2) In GradeBook revised class, add a setGrade method that sets one grade for a particular student on a particular exam. (3) In GradeBook2revised class, modify outputGrades method so that average grade for each test will also be printed out. For example, The grades are: Test 1 Test 2 Test 3 Average Student 1 87 96 7e 84.33 Student 2 68 87 90 81.67 Student 3 94 100 90 94.67 Student 4 100 81 B2 87.67 Student 5 83 65 85 Student 6 78 87 65 76.67 Student 7 85 75 83 81.00 Student 8 91 94 100 95.ee Student 9 76 72 84 77.33 Student 10 B7 93 73 84.33 Average 82.2 Lowest erade in the grade book is 65 Highest grade in the grade book is 192 (Figure 3.2) (4) Draw a UML class diagram to show the modified structure of GradeBook2revised class (including all instance variables and methods) (in GradeBook2revised.java). Save your UML class diagram in a Word document or a PDF document named "GradeBook2revised_UMLclassDiagram". (5) In GradeTest2revised class (in GradeTest2revised.java), modify the main method to ask users to input the number of students and number of exams for the GradeBook2revised object, and then to develop a loop to ask the user to enter one grade at a time by using setGrade method to add test grades for 10 students. After received all student grades from user inputs, the main method will print out the course name, and display the grade statistics by calling getCourseName method, and processGrades method. (6) Compile and test your program to make sure there is no syntax, logical, or run-time error. // Fig. 7.18: Gradebook.java // GradeBook class using a two-dimensional array to store grades. public class GradeBook2 { private String courseName; // name of course this grade book represents private int[][] grades; il two-dimensional array of student grades // two-argument constructor initializes courseName and grades array public GradeBook2(String courseName, int[][] grades) { this.courseName = courseName; this.grades = grades; } // method to set the course name public void setCourseName(String courseName) { this.courseName = courseName; } // method to retrieve the course name public string getcourseName() { return courseName; } // perform various operations on the data public void processgrades() { // output grades array output Grades(); // call methods getMinimum and getMaximum System.out.printf("%%s %d%n%s %d9%n", "Lowest grade in the grade book is", getMinimum(), "Highest grade in the grade book is", getMaximum()); // output grade distribution chart of all grades on all tests output Barchart(); } // find minimum grade public int getMinimum() { // assume first element of grades array is smallest int lowGrade - grades[0][0]; // loop through rows of grades array for (int[] studentGrades : grades) { 11 loop through columns of current row for (int grade : studentGrades) { 11 if grade less than lowGrade, assign it to lowGrade if (grade highGrade) { highGrade = grade; } 3 return highGrade; } // determine average grade for particular set of grades public double getAverage (int[] setofGrades) { int total = 0; // sum grades for one student for (int grade setofGrades) { total += grade; } // return average of grades return (double) total / setoforades. length; } 1/ output bar chart displaying overall grade distribution public void outputBarchart() { System.out.println("overali grade distribution:"); // stores frequency of grades in each range of 10 grades int[] frequency = new int[11]; // for each grade in GradeBook, increment the appropriate frequency for (int[] studentGrades : grades) { for (int grade : studentGrades) { ++frequency[grade / 10); } 3 // for each grade frequency, print bar in chart for (int count = 0; count

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Apache Cassandra 3 X An Expert Guide To Improving Database Scalability And Availability Without Compromising Performance

Authors: Aaron Ploetz ,Tejaswi Malepati ,Nishant Neeraj

3rd Edition

1789131499, 978-1789131499

More Books

Students also viewed these Databases questions