TestScores Class Write a class named TestScores. The class constructor should ac
ID: 3840800 • Letter: T
Question
TestScores ClassWrite a class named TestScores. The class constructor should accept an array of test scores as its argument. The class should have a method that returns the average of the test scores. Write an exception named InvalidTestScores, which is thrown by the TestScores class if any of the test scores in the array are invalid.
Sample Output:
Invalid score found. Element: 3 Invalid Score: 101.0 The average of the good scores is 90.24 Press any key to continue . . . TestScores Class
Write a class named TestScores. The class constructor should accept an array of test scores as its argument. The class should have a method that returns the average of the test scores. Write an exception named InvalidTestScores, which is thrown by the TestScores class if any of the test scores in the array are invalid.
Sample Output:
Invalid score found. Element: 3 Invalid Score: 101.0 The average of the good scores is 90.24 Press any key to continue . . . TestScores Class
Write a class named TestScores. The class constructor should accept an array of test scores as its argument. The class should have a method that returns the average of the test scores. Write an exception named InvalidTestScores, which is thrown by the TestScores class if any of the test scores in the array are invalid.
Sample Output:
Invalid score found. Element: 3 Invalid Score: 101.0 The average of the good scores is 90.24 Press any key to continue . . .
Explanation / Answer
public class TestScore
{
TestScores(double a,double b,double c)
{
this.a=a;
this.b=b;
this.c=c;
}
double avg(double a1,double b1,double c1)
{
double avg=0.0;
a1=a;
b1=b;
c1=c;
avg=a1+b1+c1/3
retuen avg;
}
public static void main(String args[])
{
TestScores s=new TestScores(10,20,30);
s.avg();
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.