Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Programming Question Make a class that represents an average of test scores. Make the class take an unlimited number of scores and calculate the
Java Programming Question
Make a class that represents an average of test scores. Make the class take an unlimited number of scores and calculate the number of tests taken along with the average.
Given:
public class TestScoresDemo { public static void main(String[] args) { TestScores t1 = new TestScores("Alice"); TestScores t2 = new TestScores("Bob"); t1.addTestScore(50); t1.addTestScore(60); t1.addTestScore(54); t1.addTestScore(73); t1.addTestScore(88); t1.addTestScore(92); t2.addTestScore(87); t2.addTestScore(97); t2.addTestScore(37); t2.addTestScore(99); System.out.println("-- Alice --"); System.out.println("Num tests taken: " + t1.getNumTestsTaken()); System.out.println("Average: " + t1.getAverage()); System.out.println("-- Bob --"); System.out.println("Num tests taken: " + t2.getNumTestsTaken()); System.out.println("Average: " + t2.getAverage()); } }
Required Output
-- Alice -- Num tests taken: 6 Average: 69.5 -- Bob -- Num tests taken: 4 Average: 80.0
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