#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
// Function prototype for functions
double inputExam (string examType);
double inputAndAvgQuizzes();
double inputAndAvgLabs();
// main Function
int main()
{
double midterm = 0.0;
double finalExam = 0.0;
double labs = 0.0;
double quizzes = 0.0;
double grade = 0.0;
// Call inputExam ("Midterm") to request the midterm exam grade
// and return the result to the midterm variable
// Call inputExam ("Final") to request the finalexam grade
// and return the result to the final variable
// Call inputAndAvgQuizzes () to request and average the two highest quiz grades
// and return the result to the quizzes
// Call inputAndAvgLabs () to request and average the two highest quiz grades
// and return the result to the labs variable
//Calculate and display the end of semester grade
midterm = inputExam (string midterm);
finalExam = inputExam (string Final);
labs = inputAndAvgLabs ();
quizzes = inputAndAvgQuizzes ();
grade = ((midterm * .2) + (finalExam * .2) + (labs * .5) + (quizzes * .1)) / 2
cout << grade << endl;
system("pause");
return 0;
}
double inputExam (string examType)
{
double exam;
cout << "Enter the " examType " Score: ";
cin >> exam;
return exam;
}
double inputAndAvgLabs()
{
double labGrade;
double labTotal:
double aveLab;
int numLabEnt;
cout << "Enter lab grade (Enter -1 to stop): ";
cin >> labGrade;
//repeat while when lab not -1
while (labGrade != -1)
{
labTotal = labGrade + labTotal;
numLabEnt = 1 + numLabEnt;
//calculate lab average
aveLab = labTotal/numLabEnt;
//enter lab score
cout << "Enter lab grade (-1 to stop): ";
cin >> labGrade;
}//end while
return aveLab;
}
double inputAndAvgQuizzes ()
{
double quizGrade;
double quizTotal:
double aveQuiz;
int numQuizEnt;
cout << "Enter quiz grade (Enter -1 to stop): ";
cin >> quizGrade;
//repeat while when quiz not -1
while (quizGrade != -1)
{
quizTotal = quizGrade + quizTotal;
numQuizEnt = 1 + numQuizEnt;
//calculate lab average
aveQuiz = quizTotal/numQuizEnt;
//enter quiz score
cout << "Enter quiz grade (-1 to stop): ";
cin >> quizGrade;
}//end while
return aveQuiz;
}