Question: This question involves writing a complete java class called Student. Please write the complete code for this class according to the following specification: a .
This question involves writing a complete java class called Student. Please write the complete code for this class according to the following specification:
a Fields: private fields that store the following:
i name as a String
ii id as an int
iii. scores as an ArrayList of type Integer that will store student test scores
b Constructor: This takes name and id as parameters and sets the class private fields. It also initializes the private field scores to a new empty ArrayList of type Integer.
c Methads:
i getName larr Accessor for the name private field.
ii getID larr Accessor for the id private field.
iii. BetGrade larr Returns the average of all the test scores in the scores private field.
iv addTest larr Adds a new int score to the scores private field.
v toString larr Returns a String having the following format:
ID: id Name: name, Grade: grade"
where id and name are the values in the class private fields, and the grade is the average of the student's test scores, as calculated by the method getGrade from point iii. above.
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
