Question: Write a class encapsulating the concept of student grades on a test, assuming student grades are composed of a list of integers between 0 and
Write a class encapsulating the concept of student grades on a test, assuming student grades are composed of a list of integers between 0 and 100. Write the following methods: //1.A constructor with just one parameter, the number of students; all grades can be randomly generated. //2.Accessor, mutator methods 3.A method returning an array of grades sorted in ascending order 4.A method returning the highest grade 5.A method returning the average grade 6.A method returning the median grade (Hint: The median grade will be located in the middle of the sorted array of grades 7.A method returning the mode (the grade that occurs most often.
Hint: Create an array of counters; count how many times each grade occurs; then pick the maximum in the array of counters; the array index is the mode.
Write a client class to test all of the methods in your class.
Sample output shoudl look like this: any help would be awesome!

I have the following already worked out, but I'm getting errors, please help!!
import java.io.*; import java.util.Random;
public class Grades { private int grades[]; private int size; private int[] indexCounter; //constructor with argument public Grades(int n) { this.setSize(n); //random number generator Random rand = new Random(); int[] temp = new int[n]; for(int i=0; i
------------------------------------------
import java.util.Scanner;
public class GradesClient {
/** * @param args */ public static void main(String[] args) { System.out.print("How many students are there: "); int grades = new Scanner(System.in).nextInt(); Grades g = new Grades(20); System.out.println("Sorted grades:"); g.displayGradesAscending(); System.out.println("Highest grade: " +g.highestGrade()); System.out.println("Average grade: " +g.averageGrade()); System.out.println("Median grade: " +g.medianGrade()); System.out.println("Mode: " +g.mode()); } }
El Console Problems Javadoc Declaration Kterminated GradesClient [Java cational CAI Files Javal Program re g1 Grades 14 36 25 93 71 30 88 100 93 5 92 g2: 52 61 86 35 62 73 14 71 66 82 47 objects are not equal Setting gl and g2 arrays to studentGrades Grades: 56 97 85 78 97 88 98 97 62 75 75 Comparing g1 and g2 for equality objects are equal Sorted grades: 56 62 75 75 78 85 88 97 97 97 98 The highest grade is 98 The average grade is 82.55 The median grade is 85 The mode is 97
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
