Question: java code needed: Define Student class: Student: name: student name, including first name and last name. scores [ ] : an array with three test
java code needed:
Define Student class:
Student:
name: student name, including first name and last name.
scores: an array with three test scores.
Student: constructor, creates the scores array with elements.
set and get methods for name and scores.
setScoreint index, double score: set the score to the score indexed by index.
double getScoreint index: returns test score indexed by index
double getAverage: returns the tests average.
Tasks:
a
Define Student class.
b
Write a program to test the student class:
Ask user for the number of students: n
Create a Student array with n students.
Ask user to input user's name first name and last name and three test scores.
Use set methods to set user's name and three test scores.
Sort the students by test average from high to low. Display the students information before and after sort.
Sort the students by name in alphabetical order. Display the students information before and after sort.
Sample run:
How many students?
Please input student information:
Student
Name: Iron Man
Test :
Test :
Test :
Student
Name: Captain American
Test :
Test :
Test :
Student
Name: Doctor Strange
Test :
Test :
Test :
Sort students by test average:
Before sorting:
Student: Iron Man
Test scores:
Average:
Student: Captain American
Test Score:
Average:
Student: Doctor Strange
Test scores:
Average:
After sorting:
Student: Iron Man
Test scores:
Average:
Student: Doctor Strange
Test scores:
Average:
Student: Captain American
Test Score:
Average:
Sort students by name:
Before sorting:
Student: Iron Man
Test scores:
Average:
Student: Doctor Strange
Test scores:
Average:
Student: Captain American
Test Score:
Average:
After sorting:
Student: Captain American
Test Score:
Average:
Student: Doctor Strange
Test scores:
Average:
Student: Iron Man
Test scores:
Average:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
