Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "TestScores.h"
- using namespace std;
- TestScores::TestScores(double *arr, int size)
- {
- ptr = new double[size];
- scores = size;
- for (int x = 0; x < size; x++)
- {
- double num = arr[x];
- if (num < 0 || num > 100)
- {
- throw num;
- }
- else
- {
- ptr[x] = num;
- }
- }
- }
- double TestScores::returnAverage()
- {
- double average = 0;
- for (int y = 0; y < scores; y++)
- {
- average += ptr[y];
- }
- average = (average / scores);
- return average;
- }
Add Comment
Please, Sign In to add comment