subject

Part I:
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. If any test score in the array is negative or greater than 100, the class should throw an IllegalArgumentException.
Demonstrate the class in a program and the program should ask the user to input the number of test scores to be counted, and then each individual test score. It should then make an array of those scores, create a TestScore object, and print the average of the scores. If an IllegalArgumentException is thrown, the main method should catch it, print "Test scores must have a value less than 100 and greater than 0." and terminate the program.
Part II:
Invalid TextScore Write an exception class named Invalid Test Score. Modify the TestScores class you wrote in Part I so that it throws an InvalidTestScore exception if any of the test scores in the array are invalid. Test your exception in a program (in a subclass located in the same file). Your program should prompt the user to enter the number of test scores, and then ask for each test score individually. Then, it should print the average of test scores. If the average method throws an InvalidTestScore exception, the main method should catch it and print "Invalid test score."

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 21:20
Write a select statement that returns product name, customer first name, customer last name, channel description, and amount sold for all the sales. make sure to returns sales even if there is no information on the customer, product, or channe
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Acloud service provider uses the internet to deliver a computing environment for developing, running, and managing software applications. which cloud service model does the provider offer? a. iaas b. caas c. maas d. paas e. saas
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
Which option allows you to view slides on the full computer screen?
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Drag the tiles to the correct boxes to complete the pairs. match the errors with their definitions. #name #value #ref when a formula produces output that is too lengthy to fit in the spreadsheet cell arrowright when you enter an invalid cell reference in a formula arrowright when you type text in cells that accept numeric data arrowright when you type in a cell reference that doesn’t exist arrowright reset next
Answers: 1
You know the right answer?
Part I:
Write a class named TestScores. The class constructor should accept an array of test s...
Questions
question
Mathematics, 04.09.2021 01:00
question
Physics, 04.09.2021 01:00
question
Mathematics, 04.09.2021 01:00
question
Chemistry, 04.09.2021 01:00
question
Mathematics, 04.09.2021 01:00
question
Physics, 04.09.2021 01:00
Questions on the website: 13722363