I think I spot 3 errors, the first one would be:
1 2 3 4 5 6 7 8 9 10 11
|
inputExam("Midterm");
midterm = midtermScore;
inputExam("Final");
final = finalScore;
inputAndAvgQuizzes();
quizzes = quizresult;
inputAndAvgLabs();
labs = labsresult;
|
I think that should be:
1 2 3 4 5 6 7 8
|
midterm = inputExam("Midterm");
final = inputExam("Final");
quizzes = inputAndAvgQuizzes();
labs = inputAndAvgLabs();
|
then, I think the return statements in the
inputExam
function should be inside the if block, since right now it's never going to get to
return finalScore;
Finally, I think that the problem you had with
inputAndAvgLabs
was that it was only asking for 3 grades, at least it did for me. The code below works for me, the error was inside the for loop statement, it should either be
counter < 4
or
counter <= 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
double inputAndAvgLabs(){
double total = 0.0;
double labsresult = 0.0;
std::cout << "Enter four lab grades: ";
for (int counter = 0; counter < 4; counter++){
double lab = 0.0;
std::cin >> lab;
std::cout << std::endl;
total += lab;
}
labsresult = total / 4;
return labsresult;
}
|
Sorry if I made any mistakes, I'm pretty new to C++ too. Also, a lot of people agree it's bad practice to use any of the system commands, as it's exclusive to windows and there are other ways to get the same result.