Question: Java Write a Student class based on UML diagram. And complete the main method using two methods. Use this keyword. method1: find the student information
Java
Write a Student class based on UML diagram. And complete the main method using two methods. Use this keyword.
- method1: find the student information who has the best score
- method2: compute the average of computer science students

import java.text.DecimalFormat;
import java.util.ArrayList;
public class StudentTest {
// method1 : find the student who has the best score.
// method2 : compute the average of computer science students.
public static void main(String[] args)
{
// ArrayList
ArrayList
st.add(new Student("Mark", 111, "Computer Science", 88.5));
st.add(new Student("Henry", 115, "Math", 92.3));
st.add(new Student("Oliver", 211, "Physics", 84.9));
st.add(new Student("Susan", 132, "Computer Science", 75.2));
st.add(new Student("Jason", 231, "Computer Science", 90.5));
/* Print information of the student with the best score.
You must use a method. */
/* Calculate and print the average of computer science students.
Student information in ArrayList may change. You must use a method. */
}
}

If the contents of the ArrayList are changed like below, the output should be changed accordingly.
| ArrayList st.add(new Student("Katy", 121, "Computer Science", 77.5)); st.add(new Student("Robby", 315, "Math", 66.3)); st.add(new Student("Oliver", 711, "Physics", 64.9)); st.add(new Student("Susan", 232, "Chemistry", 79.2)); st.add(new Student("Cindy", 831, "Computer Science", 66.5)); st.add(new Student("Jane", 381, "Physics", 79.9)); st.add(new Student("April", 162, "Computer Science", 85.2)); st.add(new Student("Jason", 981, "Computer Science", 81.7)); |

| ArrayList st.add(new Student("Mark", 111, "Math", 88.5)); st.add(new Student("Henry", 115, "Math", 92.3)); st.add(new Student("Oliver", 211, "Physics", 94.9)); st.add(new Student("Susan", 132, "Chemistry", 75.2)); st.add(new Student("Jason", 231, "Computer Science", 90.5)); |

Student - name : String - id : int - major : String score : double StudentTest + main(args : String[]) : void + Student (name : String) + Student (name : String, id : int) + Student (name : String, id : int, major : String) + Student (name : String, id : int, major : String, score : double) Accessors / mutators + toString() : String The student who got the best score: Henry(115, Math, 92.3) Average of Computer Science : 84.733 The student who got the best score: April(162, Computer Science, 85.2) Average of Computer Science : 77.725 The student who got the best score: Oliver (211, Physics, 94.9) Average of Computer Science : 90.5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
