Received some prior help to clean up my code and get this to compile which, it does in fact compile, but it seems to end after the int main(). I have tried several other possibilities with moving code around for the various functions, and I still cannot seem to get it to read beyond the int main().
Any help provided would be very appreciated.
Thanks in advance!
//
// Program computes student grades. For each student, two
// quiz grades, one midterm exam grade, and one final exam grade
// are read in. The final numeric grade is computed, weighing the
// the final exam as 50%, the midterm exam as 25%, and the quizzes
// at 25%. The numeric and corresponding letter grades are output.
//
#include <iostream>
#include <string>
using namespace std;
//
// Structure for a student record
//
struct StudentRecord
{
double quiz1, quiz2, midtermExam, finalExam, courseAverage, letterGrade;
};
double quiz1;
double quiz2;
double midtermExam;
double finalExam;
double courseAverage;
char letterGrade(double numericgrade);
void outputRecord(StudentRecord record);
void computeAverage (StudentRecord& record);
int main()
{
cout << "Please Enter Your Grades Below" << endl;
cout << "Quiz Scores: ";
cin >> quiz1;
cout << "and ";
cout << "\n";
cin >> quiz2;
cout << endl;
cout << "Midterm Exam Score: ";
cin >> midtermExam;
cout << endl;
cout << "Final Exam Score: ";
cin >> finalExam;
char letter;
cout << "Press any alphanumeric key and press enter to end the program:\n";
cin >> letter;
}
char letterGrade (double numericGrade)
{
char letter;
if (numericGrade < 60)
letter = 'F';
else if (numericGrade < 70)
letter = 'D';
else if (numericGrade < 80)
letter = 'C';
else if (numericGrade < 90)
letter = 'B';
else
letter = 'A';
return letter;
}
void outputRecord(StudentRecord record)
{
cout << endl;
cout << "Quiz Scores: " << record.quiz1 << " " << record.quiz2 << endl;
cout << "Midterm Exam Score: " << record.midtermExam << endl;
cout << "Final Exam Score: " << record.finalExam << endl;
cout << endl;
cout << "Course Average: " << record.courseAverage << endl;
cout << "Final Letter Grade: " << record.letterGrade << endl;
}
void computeAverage (StudentRecord& record)
{
const double EXAM_WT = 0.5;
const double MIDTERM_WT = 0.25;
const double QUIZ_WT = 0.25;
double quiz1Percent, quiz2Percent;
//
// Convert the 10 point quizzes to a percent, then find the average
//
quiz1Percent = 100 * record.quiz1 / 10.0;
quiz2Percent = 100 * record.quiz2 / 10.0;
double quizAvg = (quiz1Percent + quiz2Percent) / 2;
//
// Compute the weighted average to get the numeric course grade
//
record.courseAverage = quizAvg * QUIZ_WT + record.midtermExam * MIDTERM_WT +
record.finalExam * EXAM_WT;
//
// Call the letterGrade function to find the corresponding letter grade
record.letterGrade = letterGrade (record.courseAverage);
}