Need help to see what I did wrong and/or what am I missing
Object:
Write a program to compute the final score and the letter grade of students in a class of 5 or more students.
Each student has the following:
- An ID number(positive integer value); a dummy ID number of -99 is used to indicate the end of the input data.
- The exam score and 7 test scores. The exam score and the test scores are real values in the range 0.00 to 100.00. The final test score is computed as: 4/10(average test score)+6/10(exam score).
Input: For each student, its ID number, its exam score, and 7 test scores. The last ID number must be the dummy student ID number -99 with no exam or test scores.
1) Write the function void
readTestScores (double &exam, double &tavge) that does the following:
- print the prompt: "enter exam score:" than read the exam score
- print the prmpt: "enter all test scores:" then read 7 test scores in a loop, and than computer their average
- the exam score and the average of the test scores are returned to the calling function using the reference parameters exam and tavge respectively
2) Write the function double
computeFinalScore(double exam, double tavge) that gets a student's exam score and its test scores average using the value parameters exam and tavge respectively, computes the final score as follows, 4.0/10(test scores average)+6.0/10(exam score) and returns it to the calling function.
3) Write the function
char getLetterGrade(double score) that gets a student's final score using the value parameter score, determines the corresponding letter grades, and returns it to the calling function. The letter grade is determined as follows:
of:
score >=90 A
80 <= score<90 B
70 <= score<80 C
60 <= score<70 D
score<60 F
4) Write the function
void printComment(char grade) that gets a student's letter grade and prints the corresponding comment as follows: COMMENT: <comment>
the <comment> is determined as follows:
A very good
B good
C satisfactory
D need improvement
F poor
This is what I did so far:
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <iostream>
using namespace std;
int main()
{
void readTestScores(double&exam, double&tavge);
double computeFinalScore(double exam, double tavge);
char computeGrade(double score);
void printComment(char grade);
double exam; // a student's average exam score
double tavge; // a student's average test score
/*read the student's exam scores and compute their average*/
cout << endl << "Enter Student ID:\t";
cout << endl << "Enter exam score:\t";
/*read the student's test score and compute their average*/
cout << endl << "Enter all test scores:\t";
/*compute and print the student's average score*/
cout << endl << "The average score is:\t" << (.4 * tavge + .6 * exam);
int score;
cout << "\n Enter your marks = ";
cin >> score;
char computeGrade(int val);
{
char symb;
if(val>=90)
symb='A';
else if(val>=80)
symb='B';
else if(val>=70)
symb='C';
else if(val>=60)
symb='D';
else
symb='F';
return(symb);
}
cout<<"\n Your Grade is = ";
system("pause");
return 0;
}
|