SilverhandX

testscores.cpp

Mar 21st, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include "TestScores.h"
  3. using namespace std;
  4.  
  5. TestScores::TestScores(double *arr, int size)
  6. {
  7.     ptr = new double[size];
  8.  
  9.     scores = size;
  10.  
  11.     for (int x = 0; x < size; x++)
  12.     {
  13.         double num = arr[x];
  14.  
  15.         if (num < 0 || num > 100)
  16.         {
  17.             throw num;
  18.         }
  19.         else
  20.         {
  21.             ptr[x] = num;
  22.         }
  23.     }
  24. }
  25.  
  26. double TestScores::returnAverage()
  27. {
  28.     double average = 0;
  29.  
  30.     for (int y = 0; y < scores; y++)
  31.     {
  32.         average += ptr[y];
  33.     }
  34.  
  35.     average = (average / scores);
  36.  
  37.     return average;
  38. }
Add Comment
Please, Sign In to add comment