Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class called TestScores. The class constructor should accept an array of test scores as its argument. The class should have a member function

Write a class called TestScores. The class constructor should accept an array of test scores as its argument. The class should have a member function 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 exception. There should be two classes for the exceptions; one should be called NegativeScore and other should be TooLargeScore. These exception classes will have a data member that is an integer value called score. This data member will be set in the constructor via the parameter. It should also provide a member function called getScore which returns score data member. The function in TestScores called getAverages will calculate the average (as a double) of the test scores in the array. It will also check if the score is negative or greater than 100. If it is negative it should throw an exception using the NegativeScore class. If the score is greater than 100 it should throw an excpetion using the TooLargeScore class. Main will create the instance of the TestScores class and catch the exceptions. So it needs to handle both exceptions and display the error message with the score that is invalid.

Please explain and comment. Separate each section and comment top of section with name of the .h or .cpp

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 9th International Conference Dasfaa 2004 Jeju Island Korea March 2004 Proceedings Lncs 2973

Authors: YoonJoon Lee ,Jianzhong Li ,Kyu-Young Whang

2004th Edition

3540210474, 978-3540210474

More Books

Students also viewed these Databases questions

Question

Understanding Groups

Answered: 1 week ago