Lab to be performed in Java. Lab: 1.) Write a class named TestScores. The class constructor should accept...

70.2K

Verified Solution

Question

Programming

Lab to be performed in Java.

Lab:

1.) Write a class named TestScores. The class constructor shouldaccept an array of test scores as its argument. The class shouldhave a method that returns the average of the test scores. If anytest score in the array is negative or greater than 100, the classshould throw an IllegalArgumentException. Write a driver class totest that demonstrates that an exception happens for thesescenarios

2.) Write a class named InvalidTestScore by reusing the code inTestScores class you wrote for 1) so that it throws anInvalidTestScore exception. Write a driver class to test thatdemonstrates that an exception happens for these scenarios.

Note 1) and 2) are two separate programs that must be handed inas well as your test score array.

---- Create a class TestScores and TestScoresconstructor should accept an array of test scores as its argument.Users will enter 5 test scores use a scanner toget input from the console.

---- Create a method that returns or print toconsole the correct average of the test scores. If any test scorein the array is negative or greater than 100, the class shouldthrow an IllegalArgumentException.

---- Create a class InvalidTestScore by reusingthe code of TestScores that print to console the line “Test scorevalues should not be greater than 100 or negative” whenIllegalArgumentException is thrown.

Answer & Explanation Solved by verified expert
3.9 Ratings (643 Votes)
1 Solution import javautil    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students