Hi, I have a homework assignment similar to a problem that is on this website.
http://www.cplusplus.com/forum/beginner/143462/
Unfortunately, even after I make the corrections the post says to, it won't compile properly on visual studio. Could someone tell me what I'm doing wrong or point me in the right direction?
This is the problem and code I have so far which is similar to the code in the link I posted before. I just can't seem to get calcAverage to work correctly. It says:
Error C2660 'calcAverage': function does not take 6 arguments
and
too few arguments in function call
#include <iostream>
#include <iomanip>
using namespace std;
void getScore(int &score);
int findLowest(int, int, int, int, int, int);
void calcAverage(int, int, int, int, int, int, double&);
int main()
{
int score1, score2, score3, score4, score5, score6;
int lowest;
double average;
//Get the users test scores
getScore(score1);
getScore(score2);
getScore(score3);
getScore(score4);
getScore(score5);
getScore(score6);
//Output control
cout << fixed << showpoint << setprecision(2);
//Get the lowest test score
lowest = findLowest(score1, score2, score3, score4, score5, score6);
cout << "The lowest test score is: " << lowest << endl;
//Calculate the average test score
calcAverage(score1, score2, score3, score4, score5, lowest);
return 0;
}
void getScore(int &score)
{
cout << "Please enter your test score (enter a value from 1 to 100): ";
cin >> score;
while (score < 1 || score > 100)
{
cout << "Error: Please enter a test score from 0 to 100!";
cin >> score;
}
}
int findLowest(int score1, int score2, int score3, int score4, int score5, int score6)
{
int lowest;
lowest = score1;
if (score2 < lowest)
lowest = score2;
else if (score3 < lowest)
lowest = score3;
else if (score4 < lowest)
lowest = score4;
else if (score5 < lowest)
lowest = score5;
else if (score6 < lowest)
lowest = score6;
return lowest;
}
void calcAverage(int score1, int score2, int score3, int score4, int score5, int lowest, double& average)
{
average = (score1 + score2 + score3 + score4 + score5 - lowest) / 5;
}
Thank you.