Tags: %TAGME{ tpaction="" web="SCMP118" tag="" }% view all tags

Lab 3 - Functions

Due: Oct 3, 11:55pm

Moodle Link


Turn in

  • The code (as a cpp file),
  • A file with the collected outputs from the trial inputs below the run outputs as requested below.
  • Follow the guidelines on Program Style described in section 2.5 of the textbook. ( See guidelines here)


Write a C++ program which does the following (Below is an outline) (100 pts)

Write a program to compute the final score and the letter grade of students in a class of one 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.

You are to write a main function the uses the following functions to complete this program:

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

A sample run:

Enter numeric ID number, -99 to end:2435234
Enter Exam score: 87
Enter test score 1 :94
Enter test score 2 :87
Enter test score 3 :45
Enter test score 4 :98
Enter test score 5 :78
Enter test score 6 :90
Enter test score 7 :93
Student 2435234 Has a final grade B Good
Enter numeric ID number, -99 to end:566789
Enter Exam score:  56
Enter test score 1 :45
Enter test score 2 :65
Enter test score 3 :76
Enter test score 4 :87
Enter test score 5 :56
Enter test score 6 :76
Enter test score 7 :45
Student 566789 Has a final grade D Needs Improvement
Enter numeric ID number, -99 to end:-99

Turn in

Turn in three run samples

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2019-10-03 - JimSkon
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback