I'm getting an error on line 6 that reads "too many arguments to function 'char calcGrade'" and I'm not sure what I need to do to fix it. Any help would be appreciated.
#include <iostream>
usingnamespace std;
double getScore(); // function prototype for the function getScore
char calcGrade (); // add a function prototype for the function calcGrade here
int main()
{
double score = 0.0;
char grade = ' ';
score = getScore(); // invoke the function getScore, store return value in score
grade = calcGrade(score); // invoke the function calcGrade, pass score to it and store return value in grade
cout << "Your letter grade is: " << grade << endl;
system("pause");
return 0;
}
double getScore()
{
double myScore = 0.0;
cout << "What is your test score? ";
cin >> myScore;
return myScore;
}
char calcGrade(double testScore)
{
char letterGrade = ' ';
if (testScore >= 90)
letterGrade = 'A';
elseif (testScore >= 80)
letterGrade = 'B';
elseif (testScore >= 70)
letterGrade = 'C';
elseif (testScore >= 60)
letterGrade = 'D';
else
letterGrade = 'F';
return letterGrade;
}
you have forward declared char calcGrade (); and definition reads char calcGrade(double testScore) and you are calling it like grade = calcGrade(score);
Forward declaration and actual signature should be same.
I'm a bit confused, but I think you're saying I should change grade = calcGrade(score); to grade = calcGrade(testScore); but when I do that I get another error. Could you please expound? I'm very new to C++.