I am new to programming and have no idea how I have made it this far in the class, but this is our last assignment and I am stuck. This is what the assignment says:
Create program that calculates the average of three test scores:
The program should contain 3 value-returning functions: main (), getTestScore (), and calcAverage(). The main () function should call the getTestScore () function to get and return each of 3 test scores. The test scores may contain a decimal place. (Hint: the main () function will need to call the getTestScore function three times.) The main() function then should call the calcAverage () function to calculate and return the average of the 3 test scores. When the calcAverage() function has completed its task, the main() function should display the average on the screen. Display the average with one decimal place.
Can anyone help? It would be greatly appreciated. This is what I have now (yikes!):
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
//function prototype
double calcAverage (int, int, int);
int main()
{
//declare variables
int score1 = 0;
int score2 = 0;
int score3 = 0;
double average = 0.0;
//get input items
cout << "First test score: ";
cin >> score1;
cout << "Second test score: ";
cin >> score2;
cout << "Third test score: ";
cin >> score3;
//call function to calculate payments
average = calcAverage (int score1, int score2, int score3);
cout << "Average: " << average << endl;
return 0;
} //end of main function
//function definitions
double calcAverage (int num1, int num2, int num3)
{
double avg = 0.0;
avg = static_cast<double>(num1 + num2 + num3) / 3.0;
return avg;
} //end of calcAverage function