Question: Write a program that calculates the average of the test scores of a student. Main function: Define variables to store the sum of the test
Write a program that calculates the average of the test scores of a student.
Main function:
Define variables to store the sum of the test scores as well as the number of test scores and prompt the user for the number of test scores and Display the average of the test scores.
In a loop, the main function calls another programmer defined function
that Prompts the user for the score of the student. Only read a single score inside this function, your loop must be in the main function. do not use an array. the loop should Update the sum variable with the user provided score. The function must include the exception specification
This function can create two exceptions, The score is negative and The score is greater than 100
For each exception, it needs to throw an object. design an exception class that:
a) There is only one catch block in your code which catches both exceptions using the thrown object.
b) There should not be any default catch block in your program.
c) If score is negative, it needs to display the message: Scores cannot
be negative.
d) If score is greater than 100, it needs to display the message: Scores
cannot be greater than 100.
Your catch block needs to terminate the program if an exception occurs and average should NOT be displayed.
no global variables allowed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
