Write the following methods:
Write a client class to test all the methods in your class to finish it off
import java.util.Arrays;
import java.util.Objects;
import java.util.Random;
class StudentGrades{
int numStudents;
int grades[];
public StudentGrades(int numStudents) {
this.numStudents = numStudents;
grades = new int[numStudents];
Random r = new Random();
for(int i=0;i<numStudents;i++){
grades[i] = r.nextInt(101);
}
}
public int getNumStudents() {
return numStudents;
}
public void setNumStudents(int numStudents) {
this.numStudents = numStudents;
}
public int getHighestGrade(){
int grad = 0;
for(int x : grades){
grad = Math.max(grad,x);
}
return grad;
}
public double getAverageGrade(){
double total = 0;
for(int x : grades){
total += x;
}
return total/numStudents;
}
public int getLowestGrade(){
int grad = 101;
for(int x : grades){
grad = Math.min(grad,x);
}
return grad;
}
public String toString(){
return numStudents+" : "+ Arrays.toString(grades);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StudentGrades that = (StudentGrades) o;
return numStudents == that.numStudents &&
Arrays.equals(grades, that.grades);
}
}
class Main{
public static void main(String[] args) {
StudentGrades grades = new StudentGrades(10);
System.out.println("Grades "+Arrays.toString(grades.grades));
System.out.println("Minimum "+grades.getLowestGrade());
System.out.println("Maximum "+grades.getHighestGrade());
System.out.println("Average "+grades.getAverageGrade());
}
}
OUTPUT :

Using Java Write a class encapsulating the concept of student grades (50 elements) on a test,...
Write a class encapsulating the concept of daily temperatures for a week with a single dimensional array of temperatures. Write the following methods: • A constructor accepting an array of seven temperatures as a parameter. • Accessor, mutator, toString() and equals() methods • A method returning how many temperatures were below freezing. • A method returning an array of temperatures above 100 degrees. • A method returning the largest change in temperature between any two consecutive days. • A method...
write a class encapsulating the concept of a student assuming
that the student has the following attributes the name of student
the average of the student the
rite a class encapsulating the concept of a Student, assuming that the Student has the following attributes: the name of the student, the average of the student, and the student's GPA. Include a default constructor, an overloaded constructor, the accessors and mutators, and methods, toString() and equals(). Also include a method returning the...
Write a class encapsulating the concept of a vendor, if a vendor has the following attributes: company name, id, array of quarterly purchase order totals (4 double elements). Include a constructor, accessor, mutator, and toString methods. Also code the following methods: one returning the total purchase orders (total all array elements) and a method to modify an array element (change the value of an array element). Write a client class to create 2 vendor objects and test all your methods.
In Java, Write a class encapsulating a restaurant,which inherits from Store. A restaurant has the following additional attributes: how many people are served every year and the average price per person. code the constructor, accessors, mutators, toString and equals method of the new subclass; also code a method returning the average taxes per year. You also need to include a client class to test your code for both the parent class and the subclass. Code for Store below(Super class aka...
Write a class encapsulating the concept of a television set, assuming a television set has the following attributes: a brand and a price. include a constructor, the accessors and mutators, and methods to string and equals. Write a client class to test all the methods in your class.
In JAVA, please In this module, you will combine your knowledge of class objects, inheritance and linked lists. You will need to first create an object class encapsulating a Trivia Game which INHERITS from Game. Game is the parent class with the following attributes: 1. description - which is a string 2. write the constructor, accessor, mutator and toString methods. Trivia is the subclass of Game with the additional attributes: 1. trivia game id - integer 2. ultimate prize money...
You will need to first create an object class encapsulating a Trivia Game which INHERITS from Game. Game is the parent class with the following attributes: description - which is a string write the constructor, accessor, mutator and toString methods. Trivia is the subclass of Game with the additional attributes: 1. trivia game id - integer 2. ultimate prize money - double 3. number of questions that must be answered to win - integer. 4. write the accessor, mutator, constructor,...
IN JAVA Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
[CODE] Write a class encapsulating the concept of a house, assuming a house has the following attributes: value (in dollars), a city location, and number of bedrooms. Your class name should be “House” and your code should be in a file called “House.java”. You will need to create this file. In this class, include: Private instance variables for the previously-mentioned attributes A default constructor An overloaded constructor Accessor and mutator methods (i.e., get and set methods) The toString method The...