1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include<iostream>
#include<iomanip>
using namespace std;
void getTestScores(double &s1, double &s2, double &s3);
double calcAverage(double &score1, double &score2, double &score3);
void displayAverage(double av);
int main()
{
double a, b, c;
double x, y, z;
double ave = 0;
getTestScores(a,b,c);
ave = calcAverage(a,b,c);
displayAverage(ave);
cout << endl;
return 0;
}
void getTestScores(double &s1, double &s2, double &s3)
{
cout << "Enter a score: ";
cin >> s1;
cout << "Enter another score: ";
cin >> s2;
cout << "Enter another score: ";
cin >> s3;
cout << endl;
}
double calcAverage(double &score1, double &score2, double &score3)
{
double average = 0;
average = (score1 + score2 + score3)/3;
return average;
}
void displayAverage(double av)
{
cout << "Average is: " << av;
}
|