Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

}

}

image text in transcribed

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));

image text in transcribed

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));

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions