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

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

//

}

{
char letter;

letter = 'F';
letter = 'D';
letter = 'C';
letter = 'B';
else
letter = 'A';

return letter;
}

I dont know this is right or not, someone help me to figure it out.
0
cuong5985
1 Solution

Commented:
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

Commented:
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
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 << 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.