1A- Code a multi-threaded Java application that displays a student who has the highest GPA in a class. You must code two classes, namely HighestGPA and Worker. For the HighestGPA class, you only need to code the main method. The main method will do the following tasks:

It invokes a static method to have an ArrayList of student objects. The static method is declared in the HighestGPA class as follows:

public static ArrayList getStudents( );

It creates 3 threads to search three separate arrays of students and find out three students with the highest GPAs among their own peers. (Note: You must use the ArrayList to create three arrays of students. You can assume that the total number of students stored in the ArrayList is divided evenly by 3. In other words, each thread has the same number of students as its workload. )

It displays the student with the highest GPA. (Note: If two or more students have the same highest GPA, the main method will select the youngest student. This rule of selecting the youngest student also applies to the threads. We assume that all students have different ages.)

The Worker class is used to create threads as Java objects. It has a constructor that takes an array of student objects. A Worker thread will find the student with the highest GPA. You must code this class completely. You may use the Student class in your coding.

You are not required to code the Student class. It has the following API:

public Student( );
public Student( String name, double gpa, int age );
public String getName();
public double getGPA();
public int getAge();
public void setName( String name );
public void setGPA( double gpa );
public void setAge( int age );

Here is a possible scenario.

There are 9 students in the ArrayList:

  • 1. student name: John Doe, GPA: 3.45, age: 33
  • 2. student name: John Deer, GPA: 2.59, age: 22
  • 3. student name: John Alexander, GPA 3.45, age: 35
  • 4. student name: April Walton, GPA: 2.22, age: 21
  • 5. student name: May Sanders, GPA: 3.45, age: 23
  • 6. student name: Lisa Grooms, GPA: 2.59, age: 24
  • 7. student name: Paul Newman, GPA: 3.0, age: 27
  • 8. student name: Paul Snow, GPA: 2.59, age: 29
  • 9. student name: Paul Summers, GPA: 2.59, age: 19

The first thread will search an array of the first three students. It will find “John Doe” to be the student with the highest GPA. The second thread will search an array of the next three students. It will find “May Sanders” to be the student with the highest GPA. The third thread will search an array of the last three students. It will find “Paul Newman” to be the student with the highest GPA. The main method will select “May Sanders” as the youngest student with the highest GPA.

1-B Code a multi-threaded Java application that displays a student who has the lowest GPA in a class. You must code two classes, namely LowestGPA and SearchThread. For the LowestGPA class, you only need to code the main method. The main method will do the following tasks:

It invokes a static method to have an ArrayList of student objects. The static method is declared in the LowestGPA class as follows:

public static ArrayList getStudents( );

It creates 3 threads to search three separate arrays of students and find out three students with the lowest GPAs among their own peers. (Note: You must use the ArrayList to create three arrays of students. You can assume that the total number of students stored in the ArrayList is divided evenly by 3. In other words, each thread has the same number of students as its workload. )

It displays the student with the lowest GPA. (Note: If two or more students have the same lowest GPA, the main method will select the youngest student. This rule of selecting the youngest student also applies to the threads. We assume that all students have different ages.)

The SearchThread class is used to create threads as Java objects. It has a constructor that takes an array of student objects. A Worker thread will find the student with the highest GPA. You must code this class completely. You may use the Student class in your coding.

You are not required to code the Student class. It has the following API:

public Student( );
public Student( String name, double gpa, int age );
public String getName();
public double getGPA();
public int getAge();
public void setName( String name );
public void setGPA( double gpa );
public void setAge( int age );

Here is a possible scenario.

There are 9 students in the ArrayList:

  • 1. student name: John Doe, GPA: 2.0, age: 33
  • 2. student name: John Deer, GPA: 2.59, age: 22
  • 3. student name: John Alexander, GPA 3.45, age: 35
  • 4. student name: April Walton, GPA: 2.22, age: 21
  • 5. student name: May Sanders, GPA: 2.0, age: 23
  • 6. student name: Lisa Grooms, GPA: 2.59, age: 24
  • 7. student name: Paul Newman, GPA: 2.33, age: 27
  • 8. student name: Paul Snow, GPA: 2.59, age: 29
  • 9. student name: Paul Summers, GPA: 2.59, age: 19

The first thread will search an array of the first three students. It will find “John Doe” to be the student with the lowest GPA. The second thread will search an array of the next three students. It will find “May Sanders” to be the student with the lowest GPA. The third thread will search an array of the last three students. It will find “Paul Newman” to be the student with the lowest GPA. The main method will select “May Sanders” as the youngest student with the lowest GPA.

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.