Please send questions to
st10@humboldt.edu .
/*-----
Contract: main: void -> int
Purpose: testing program for the function sum_plus_avg
Examples: when this program is run, the following should
be printed to the screen:
testing sum_plus_avg: true's should mean passed:
------------------------------------------------
(lengths_sum == 137.6): true
(abs(lengths_avg - 22.9333) < .001): true
(lengths_sum == 0.0): true
(lengths_avg == 0.0): true
by: Sharon Tuttle
last modified: 04-27-10
-----*/
#include <iostream>
#include <cmath>
#include "sum_plus_avg.h"
using namespace std;
int main()
{
const int NUM_LENGTHS = 6;
double lengths[NUM_LENGTHS] = {2, 7.5, 10, 18, 0.1, 100};
double lengths_sum;
double lengths_avg;
sum_plus_avg(lengths, NUM_LENGTHS, lengths_sum, lengths_avg);
cout << boolalpha;
cout << endl;
cout << "testing sum_plus_avg: true's should mean passed: " << endl;
cout << "---------------------------------------" << endl;
cout << "(lengths_sum == 137.6): " << (lengths_sum == 137.6) << endl;
cout << "(abs(lengths_avg - 22.9333) < .001): "
<< (abs(lengths_avg - 22.9333) < .001) << endl;
cout << endl;
// Example for boundary case:
sum_plus_avg(lengths, 0, lengths_sum, lengths_avg);
cout << "(lengths_sum == 0.0): " << (lengths_sum == 0.0) << endl;
cout << "(lengths_avg == 0.0): " << (lengths_avg == 0.0) << endl;
cout << endl;
return EXIT_SUCCESS;
}