subject

In this exercise, complete the method getMostImprovedStudent in the Classroom class, as well as the method getExamRange in the Student class. The most improved student is the one with the largest exam score range. To compute the exam score range, you must subtract the minimum exam score from the maximum exam score. For example, if the exam scores were 90, 75, and 84, the range would be 90 - 75 The toString method in the Student class will print the student names with their respective grade levels. Then print who the most improved student was after this.
Sample output:
Ada Lovelace is in grade: 12
Alan Turing is in grade: 11
The most improved student is Ada Lovelace
Code that was given to edit and complete below:
public class ClassroomTester
{
public static void main (String[] args)
{
Classroom c = new Classroom(2);
Student ada = new Student("Ada", "Lovelace", 12);
ada. addExamScore(44);
ada. addExamScore(65);
ada. addExamScore(77);
Student alan = new Student("Alan", "Turing", 11);
alan. addExamScore(38);
alan. addExamScore(24);
alan. addExamScore(31);
// add students to classroom
c. addStudent(ada);
c. addStudent(alan);
c. printStudents();
Student mostImproved = c. getMostImprovedStudent();
System. out. println("The most improved student is " + mostImproved. getName());
}
}
public class Classroom
{
Student[] students;
int numStudentsAdded;
public Classroom(int numStudents)
{
students = new Student[numStudents];
numStudentsAdded = 0;
}
public Student getMostImprovedStudent()
{
// your code goes here!
}
public void addStudent(Student s)
{
students[numStudentsAdded] = s;
numStudentsAdded++;
}
public void printStudents()
{
for(int i = 0; i < numStudentsAdded; i++)
{
System. out. println(students[i]);
}
}
}
public class Student
{
private static final int NUM_EXAMS = 4;
private String firstName;
private String lastName;
private int gradeLevel;
private double gpa;
private int[] exams;
private int numExamsTaken;
/**
* This is a constructor. A constructor is a method
* that creates an object -- it creates an instance
* of the class. What that means is it takes the input
* parameters and sets the instance variables (or fields)
* to the proper values.
*
* Check out StudentTester. java for an example of how to use
* this constructor.
*/
public Student(String fName, String lName, int grade)
{
firstName = fName;
lastName = lName;
gradeLevel = grade;
exams = new int[NUM_EXAMS];
numExamsTaken = 0;
}
public int getExamRange()
{
// your code goes here!
}
public String getName()
{
return firstName + " " + lastName;
}
public void addExamScore(int score)
{
exams[numExamsTaken] = score;
numExamsTaken++;
}
// This is a setter method to set the GPA for the Student.
public void setGPA(double theGPA)
{
gpa = theGPA;
}
/**
* This is a toString for the Student class. It returns a String
* representation of the object, which includes the fields
* in that object.
*/
public String toString()
{
return firstName + " " + lastName + " is in grade: " + gradeLevel;
}
}

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 10:20, chonawilson4
Suppose there is a relation r(a, b, c) with a b+-tree index with search keys (a, b).1. what is the worst-case cost of finding records satisfying 10 < a < 50 using this index, in terms of the number of records n1, retrieved and the height h of the tree? 2. what is the worst-case cost of finding records satisfying 10 < a < 50 and 5 < b < 10 using this index, in terms of the number of records n2 that satisfy this selection, as well as n1 and h defined above? 3. under what conditions on n1 and n2, would the index be an efficient way of finding records satisfying the condition from part (2)?
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, fordkenae
Which is a possible benefit of having a good credit history? having a checking account low interest rate on a car loan high interest rate on a credit card offer bankruptcy
Answers: 1
image
Computers and Technology, 24.06.2019 08:10, anthonysutton82
Where are american poets found in the dewey decimal system
Answers: 1
image
Computers and Technology, 25.06.2019 05:00, adajadavis2843
Which of the following statements best deceive the relationship between carrying capacity and population size
Answers: 1
You know the right answer?
In this exercise, complete the method getMostImprovedStudent in the Classroom class, as well as the...

Questions in other subjects:

Konu
Mathematics, 03.03.2021 07:10
Konu
Mathematics, 03.03.2021 07:10
Konu
History, 03.03.2021 07:10