Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ISTE-120 Lab 05: Implementing Classes & Data Types Exercise 1-Implementing a class and tester (10 points) The exercise must be completed during the lab period
ISTE-120 Lab 05: Implementing Classes & Data Types Exercise 1-Implementing a class and tester (10 points) The exercise must be completed during the lab period wnte a simple class grade report program. This will work for a class of exactly three students (quite a limitation). Write a class to represent the student's record. This class (named Student) should have a constructor to which we will pass the student's name (String) and id number (int). It will have attributes for these two values, plus two other attributes which we could call sumGrades and numGrades, both ints and both initialized to zero. Besides the constructor, write a method public void addGrade (int newGrade) which will add the grade to sumGrades and will also add 1 to numGrades. Also, write a method public double getAverage () which calculates the student's average (this is the sum of the grades divided by the number of grades integer division here). .beware of Finally, write a toString method in this class: public String tostring () which will return a string formatted as follows: ame That's 10 characters for the name (exactly, no overflow), left justified, then a space, then 5 characters for the id right justified, then a space, then 7 Characters for the grade (right justified) with 2 spaces to the right of the decimal point. Use String.format in this method. Now, write another class named (the Tester) Report3. The main program is here and will follow the following input/output script: studentl: Name: Fred Smith ID: 12345 Gradel: 8o Grade2: 70 Grade3: 80 Student2: Name: Martha Stewart ID: 54321 Gradel: 90 Grade2: 60 Grade3: 75 Student3: Page 1 of 2
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