Link to home
Start Free TrialLog in
Avatar of cuong5985
cuong5985

asked on

Structure program to grading for a class.

Write a grading program for a class with the following grading policies;
there are two quizzes, each graded on the basic of 10 point
thre is one midterm exam and one final exam, each graded on the basis of 100 points
the final exam counts for 50% of the grade, the mideterm counts for 25% and two quizzes together count for total 25%.

Any grade of 90 or more is A, 80 or more is B, 70 or more is C, 60 or more is D, and less than 60 is F.
The program will read in the student's scores and output the student's record which consist of two quiz and two exam scores as well as the students's average numeric score for the entire course and the final letter grade, define and use a structure for the student record.

#include <iostream>

using namespace std;

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

}



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


I dont know this is right or not, someone help me to figure it out.
Avatar of KurtVon
KurtVon

Well, you seem to be missing a "main" function, and there is no definition for "StudentRecord", but you may have just left that out.  The rest doesn't look problematic.

Is there any reason why you don't just run it and see if it works?
ASKER CERTIFIED SOLUTION
Avatar of novitiate
novitiate

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial