Design and implement a class called Grades that stores an array of int (grades). The class will contain the following methods/operations:

  • highest - returns the highest grade
  • lowest - returns the lowest grade
  • number of grades - returns the number of grades in the array
  • average - returns the average of all the grades
  • number of failing grades - takes in a grade value and returns the number of grades below the input grade value.
  • histogram - creates a histogram that allows you to visually inspect the frequency distribution of grades.
90 – 100 | ****
80 – 89 | **********
70 – 79 | ********
60 – 69 | ****
< 60 | **

Write a main method to test out this object. In the main program, allow the user to enter the grades into the array. Since you would need to know the size of the array beforehand, you would prompt the user to first enter the number of grades and then prompt the user to enter each grade. Valid grade values are 0 - 100 inclusive.

For Example:

Enter the number of grades to input: 5
Enter grade 1: 90
Enter grade 2: 80
Enter grade 3: 70
Enter grade 4: 85
Enter grade 5: 95

Class definition:

class Grades {

private int[] values;

Grades () {…};
Grades (int[] myArray) {…};
public void setValues(int[] myArray) { // set values declaration };
public int[] getValues() { // returns values array};
public int highest() {// returns the highest value in array };
public int lowest() {// returns the lowest value in array };
public int numOfGrades() {// returns the number of grades in array };
public double average() { // returns the average of array };
public int numOfFailingGrades(int gradeValue) { // returns the number of values in the array that are less than input value, gradeValue };
public void histogram() { // prints the histogram of grades };
}
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.