Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions