Lab 3 - Functions

Due: Feb 20, 11:55pm

Moodle Link

Function.png

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)

Problem

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

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

Topic revision: r1 - 2019-09-12 - JimSkon
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback