Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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