• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2690
  • Last Modified:

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.
0
cuong5985
Asked:
cuong5985
1 Solution
 
KurtVonCommented:
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?
0
 
novitiateCommented:
like KurtVon said every thing seems to be ok. Some optimization can be done, but its not that significant. What exactly are you looking for.

Besides I suggest you change the signature of void outputRecord (StudentRecord record) to void outputRecord (const StudentRecord & record)
or
overload << operator
ostream & operator <<(ostream & os , StudentRecord & record)
{
  os << endl;
  os << "Quiz Scores: " << record.quiz1 << "  " << record.quiz2 << endl;
  os << "Midterm Exam Score: " << record.midtermExam << endl;
  os << "Final Exam Score: " << record.finalExam << endl;
  os << endl;
  os << "Course Average: " << record.courseAverage << endl;
  os << "Final Letter Grade: " << record.letterGrade << endl;
  os << endl;
  return os;

}

_novi_
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now