Computers and Technology

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;
}
}

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:30, capo9972
Write a program that takes in 3 inputs [players (int type), expected game time (double type), team (char type)] and calculates actual game time (double) based on the following conditions: if the number of players or the expected game time is less than or equal to zero, it should output wrong input if the number of players is greater than 0 and less than or equal to 6 and if they are on the â€r’ or â€r’ team, their game time will be 10% faster. and if they are on the â€b’ or â€b’ team, their game time will be 15% faster. and if they are on the â€y’ or â€y’ team, their game time will be 20% faster. and if they are on any other team, they will play 0% faster. if the number of players is greater than 6 but less than or equal to 12 and if they are on the â€r’ or â€r’ team, their game time will be 20% faster. and if they are on the â€b’ or â€b’ team, their game time will be 25% faster. and if they are on the â€y’ or â€y’ team their game time will be 30% faster. and if they are on any other team, they will play 0% faster. if the number of players is greater than 12 but less than or equal to 18 and if they are on the â€r’ or â€r’ team, their game time will be 30% faster. and if they are on the â€b’ or â€b’ team, their game time will be 35% faster. and if they are on the â€y’ or â€y’ team, their game time will
Answers: 2
image
Computers and Technology, 22.06.2019 04:30, justbepunky
There is a simple pattern for determining if a binary number is odd. what is it and why does this pattern occur? how many bits would you need if you wanted to have the ability to count up to 1000? how high could you count in binary if you used all 10 of your fingers as bits? (finger up means 1, finger down means 0)
Answers: 3
image
Computers and Technology, 22.06.2019 16:30, mesposito
Technician a says that a dry sump system uses no oil storage sump under the engine. technician b says that a wet sump system uses no oil storage sump under the engine. who is correct?
Answers: 3
image
Computers and Technology, 22.06.2019 21:30, aesthetickait
How do you take a green screen out of the video while editing?
Answers: 2
Do you know the correct answer?
In this exercise, complete the method getMostImprovedStudent in the Classroom class, as well as the...

Questions in other subjects:

Konu
French, 26.01.2021 03:40
Konu
Mathematics, 26.01.2021 03:40