You are responsible for adding the appropriate testing code to your main. a. The getValedictorian method returns the valedictorian of the class, that is the student with the highest grade point average. Implement this new method. b. The getHonorsPercent method returns the percentage of students in the class who are in the honors program. Use 3.75 as the cutoff GPA. Implement this method. Also print the list of students, by using the isHonor method, in the Honors program. c. An alternate implementation for the School class is being considered, in which the students are stored in an ArrayList instead of an array.  Show how the declaration of the data field students would look in this alternate design. MAIN CLASS: import java.util.ArrayList; public class Main {     public static void main(String[] args) {         System.out.println("Unit07Project2 by Your Name");        System.out.println();        int size = 10;        School onw = new School(size);        /*         Add the code necessary to test the project here.        */     } } class School  {     private ArrayList students;     //private Student[] students;     private int size;          public School (int s)     {       size = s;       students = new ArrayList();       addData();     }          public void addData()     {       String[] names = {"Tom", "Ann", "Bob", "Jan", "Joe", "Sue", "Jay", "Meg", "Art", "Deb"};       int[] ages = {21, 34, 18, 45, 27, 19, 30, 38, 40, 35};       double[] gpas = {1.685, 3.875, 2.5, 4.0, 2.975, 3.225, 3.65, 2.0, 3.999, 2.125};       for(int i = 0; i < size; i++)       {           Student stu = new Student(names[i], ages[i], gpas[i]);           students.add(stu);       }     }      //returns the valedictorian of the class       public Student getValidictorian()     {     }     //return the percentage of students in the honors program     public double getHonorsPercentage()     {     }     // returns true if the student is in the honors program     public boolean isHonors()     {              }      //sort by name     public void bubbleSort()     {         int n = size - 1;         for (int p = 1; p <= n; p++) {             for(int q = 0; q <= n - p; q++ ) {                 if(students.get(q).getName().compareTo(students.get(q+1).getName()) > 0) {                     Student temp = students.get(q);                     students.set(q, students.get(q+1));                     students.set(q+1, temp);                 }             }         }     }     //sort by age     public void selectionSort() {          int min;                  for(int i = 0; i < size; i++)         {             min = i;             for(int k = i + 1; k < size; k++)             {                 if(students.get(k).getAge() < students.get(min).getAge())                 {                     min = k;                 }             }             Student temp = students.get(i);             students.set(i, students.get(min));             students.set(min, temp);         }      }     public void insertionSort() {          int n = size-1;         for(int i = 0; i <= n; i++)         {             Student temp = students.get(i);             double tempGPA = temp.getGPA();             int pos = i + 1;             int index = 0;             while (index < pos && tempGPA > students.get(index).getGPA())             {                 index++;             }             for(int j = pos - 1; j > index; j--)               {                   students.set(j, students.get(j - 1));               }             students.set(index, temp);         }       }                public String toString()     {        String stu = "";        for(Student student : students)        {            stu = stu + student.toString();        }        return stu;    }            } STUDENT CLASS: // Student.java  // Used by the Lab06 and Lab07 Assignments as well   public class Student   {      private String name;      private int age;      private double gpa;           public Student (String n, int a, double g)     {        name = n;        age = a;        gpa = g;     }          public String getName() { return name; }       public int getAge()     { return age; }       public double getGPA()  { return gpa; }             public String toString()     {        String temp = name + "  " + age + "  " + gpa + "\n";        return temp;     }  }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter7: Using Methods
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question

You are responsible for adding the appropriate testing code to your main.

a. The getValedictorian method returns the valedictorian of the class, that is the student with the highest grade point average. Implement this new method.

b. The getHonorsPercent method returns the percentage of students in the class who are in the honors program. Use 3.75 as the cutoff GPA. Implement this method. Also print the list of students, by using the isHonor method, in the Honors program.

c. An alternate implementation for the School class is being considered, in which the students are stored in an ArrayList instead of an array.  Show how the declaration of the data field students would look in this alternate design.

MAIN CLASS:

import java.util.ArrayList;
public class Main {

    public static void main(String[] args) {
        System.out.println("Unit07Project2 by Your Name");
       System.out.println();
       int size = 10;
       School onw = new School(size);

       /*
        Add the code necessary to test the project here.
       */
    }

}
class School
 {
    private ArrayList<Student> students;
    //private Student[] students;
    private int size;
    
    public School (int s)
    {
      size = s;
      students = new ArrayList<Student>();
      addData();
    }
    
    public void addData()
    {
      String[] names = {"Tom", "Ann", "Bob", "Jan", "Joe", "Sue", "Jay", "Meg", "Art", "Deb"};
      int[] ages = {21, 34, 18, 45, 27, 19, 30, 38, 40, 35};
      double[] gpas = {1.685, 3.875, 2.5, 4.0, 2.975, 3.225, 3.65, 2.0, 3.999, 2.125};
      for(int i = 0; i < size; i++)
      {
          Student stu = new Student(names[i], ages[i], gpas[i]);
          students.add(stu);
      }
    } 
    //returns the valedictorian of the class  
    public Student getValidictorian()
    {

    }
    //return the percentage of students in the honors program
    public double getHonorsPercentage()
    {

    }
    // returns true if the student is in the honors program
    public boolean isHonors()
    {
        
    }
     //sort by name
    public void bubbleSort()
    {
        int n = size - 1;
        for (int p = 1; p <= n; p++) {
            for(int q = 0; q <= n - p; q++ ) {
                if(students.get(q).getName().compareTo(students.get(q+1).getName()) > 0) {
                    Student temp = students.get(q);
                    students.set(q, students.get(q+1));
                    students.set(q+1, temp);
                }
            }
        }
    }
    //sort by age
    public void selectionSort() { 
        int min;
        
        for(int i = 0; i < size; i++)
        {
            min = i;
            for(int k = i + 1; k < size; k++)
            {
                if(students.get(k).getAge() < students.get(min).getAge())
                {
                    min = k;
                }
            }
            Student temp = students.get(i);
            students.set(i, students.get(min));
            students.set(min, temp);
        }
     }
    public void insertionSort() { 
        int n = size-1;
        for(int i = 0; i <= n; i++)
        {
            Student temp = students.get(i);
            double tempGPA = temp.getGPA();
            int pos = i + 1;
            int index = 0;
            while (index < pos && tempGPA > students.get(index).getGPA())
            {
                index++;
            }
            for(int j = pos - 1; j > index; j--)
              {
                  students.set(j, students.get(j - 1));
              }
            students.set(index, temp);
        } 
     }     
   
 
    public String toString()
    {
       String stu = "";
       for(Student student : students)
       {
           stu = stu + student.toString();
       }
       return stu;
   } 
   
    
 }

STUDENT CLASS:

// Student.java
 // Used by the Lab06 and Lab07 Assignments as well
  public class Student
  {
     private String name;
     private int age;
     private double gpa;
     
    public Student (String n, int a, double g)
    {
       name = n;
       age = a;
       gpa = g;
    }
    
    public String getName() { return name; }  
    public int getAge()     { return age; }  
    public double getGPA()  { return gpa; }
       
    public String toString()
    {
       String temp = name + "  " + age + "  " + gpa + "\n";
       return temp;
    }
 }
Expert Solution
Step 1

The JAVA code is given below with output screenshot

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,