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);

}

You will need a loop someplace to calculate more than one students grade, probably using everything in main() up to but not including this line:

char letter;

as the body of the loop.

You either need these:

double quiz1;
double quiz2;
double midtermExam;
double finalExam;
double courseAverage;

which, by the way would be better off declared in main() as variables with local scope and not outside of main() as variables with global scope, or, since you've gone to the trouble of declaring your own type called StudentRecord, and indicate you plan to send objects of type StudentRecord to your functions, you coud declare StudentRecord object in main() and input information directly into the objects member variables; but you shouldn't need both the individual variables and a StudentRecord object.

Your functions are all well and good, but you have to call them in order for you to use them. Declaring prototypes and defining the functions isn't enough. (Coming up with a better name for letterGrade() would be nice. Maybe, obtainLetterGrade() or something else more descriptive than letterGrade() which sounds like it should be the name of a variable, but not a function. )

You'll probably want to call the functions within the loop I talked about above, after you've obtained all the scores for a given student.

You'll probably want to call them in the following order:

computeAverage()
obtainLetterGrade()
outputRecord()

It was not necessary to loop this for multiple students. However, thank you for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.