Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a \"TestScores\" Class that has fields to hold three test scores. The cla

ID: 3652996 • Letter: D

Question

Design a "TestScores" Class that has fields to hold three test scores. The class constructor should accept three test scores as arguments and assign these arguments to the test score fields. The class should also have accessor methods for the test score fields, a method that returns the average of the test scores, and a method that returns the letter grade that is assigned for the test score average. Then write a driver class called "TestScoresDemo" to test the class.

Explanation / Answer

public class TestScores { int score[3]; public class TestScoes(int t1,int t2,int t3) { score[0]=t1; score[1]=t2; score[2]=t3; } double getAverage() { return ((score[0]+score[1]+score[2])*1.0)/3; } char getGrade() { if(getAverage>=90) return 'A'; if(getAverage>=80) return 'B'; if(getAverage>=70) return 'C'; if(getAverage>=60) return 'D'; if(getAverage>=40) return 'P'; return 'F'; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote