Trying to create a program that calculates the average of three test scores. I have to have three value-returning functions. My book also says that I will need use getTestScore() function three times. This is where I am messing up I believe. Below is what I have so far please help:
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::setprecision;
//function prototype
int getTestScore();
double calcAverage(int, int, int);
int main()
{
int score1 = 0;
int score2 = 0;
int score3 = 0;
double averageAmt = 0.0;
cout << "Average:" << averageAmt << endl;
return 0;
} //end of main function
//*****function definitions*****
int getTestScore(int score1)
{
int score1 = 0;
cout << "Enter test score:";
cin >> score1;
return score1;
}
int getTestScore(int score2)
{
int score2 = 0;
cout << "Enter test score:";
cin >> score2;
return score2;
}
int getTestScore(int score3);
{
int score3 = 0;
cout << "Enter test score:";
cin >> score3;
return score3;
} //end of getTestScore function
double calcAverage (int score1, int score2, int score3)
{
you really only need one gettestscore function. I think you are missing the point of the functions. They don't run after main completes, you need to call them from main like this: