Question
Write a class named TestScores. The class constructor should accept an array of integer test_scores and the count of test_scores as its arguments and set
Write a class named TestScores. The class constructor should accept an array of integer test_scores and the count of test_scores as its arguments and set two protected member variable: an integer pointer for tests and an integer for the count of tests. Assign the tests pointer the base address of the passed integer test_scores array and the value of passed test_scores count to count. The class will also 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 will throw a INVALID_TESTSCORE exception. Create the empty class InvalidTestScore to be used as the exception object. Write the class and main to demonstrate the class constructor and the calculate average member function in a program. Main can be written however you like (menu based or one run and done, static array or dynamic array of test scores, prompt user for testscores or array initialization list)
to start with
#include
#include
#include
using namespace std;
protected: int* test; int count; public: TestScores(const int[], int); float calcAverage();
};
//All the way down is notes I took from class. I already started the code above, and would like to use that start from that. We are using most of those libraries for c++. Thank you!!
/*
//these are my notes
try{
} catch( //yes){
}catch(// ){
}catch(//...){
//default
}
//more notes
class INVALID_TESTSCORE{};
//float calc Average()
total=0, res=0
for(....)
if(testscore is OutofRange)
throw(Invalid test score())
//update total
return avg;
}
// Main
TestScores ts(arr, count);
float avg;
try{
avg=ts calcAverage();
}catch(INVALID_TESTSCORE err){
cout << "invalid../n";
}while(flag)
*/
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