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)); |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started