I am doing a lab practice and I'm stucked in some part... below is my question
Write a grading program for a class with the following grading policies:
a. There are two quizzes, each graded on the basis of 10 points.
b. There is one midterm exam and one final exam, each graded on the basis of 100 points.
c. The final exam counts for 50% of the grade, a midterm counts for 25% and the two quizzes together count for a total of 25%.
Any grade of 90 or more is an A, any grade of 80 or more (but less than 90) is a B, any grade of 70 or more (but less than 80) is a C, any grade of 60 or more (but less than 70) is a D, and any grade below 60 is an F.
The program will read in the student’s score and output the student’s record, which consists of two quiz and two exam scores as well as the student’s average numeric score for the entire course and the final letter grade. Define and use structure for the student record.
So far my code is like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <iostream>
using namespace std;
struct student_result{
int quiz1,quiz2; int midterm;
int final;
double total_mark;
};
int main()
{
struct student_result result;
cout<< "Enter first quiz mark: " << result.quiz1<<endl;
cin>>result.quiz1;
cout<< "Enter second quiz mark: "<< result.quiz2<<endl;
cin>>result.quiz2;
cout<< "Enter midterm exam mark: "<< result.midterm<<endl;
cin>>result.midterm;
cout<< "Enter final exam mark: " << result.final<<endl;
cin>>result.final;
system ("pause");
}
|
i know how to write the calculate function, but i duno exactly how it could be work with struct...and should I place the student input part under a function call
void getResult()
instead of under the main program or what? somore I get weird numbers when the program output display the line " Enter first quiz mark:(this is where the weird number is) " ...can anyone solve my problems?