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

Java Write a Student class based on UML diagram. And complete the

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 = new 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. */

}

}

main method using two methods. Use this keyword. method1: find the student

If the contents of the ArrayList are changed like below, the output should be changed accordingly.

ArrayList st = new 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));

information who has the best score method2: compute the average of computer

ArrayList st = new 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));

science students import java.text.DecimalFormat; import java.util.ArrayList; public class StudentTest { // method1

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!