Is anyone able to figure this out?
Professor Nutty, who lectures encephalopathy (Med 7010), at the Cajun
Medical School gave three equally weighted exams to his students during the
course (preliminary, middle, and terminal exams). The students’ scores are
kept in a text file. Each row of the text file consists of the student’s ID#
followed by his/her test scores. At the end of the course, Professor Nutty
needs a C++ program that computes average test scores and letter grades
for each student. Professor Nutty wants a report consisting of each student’s
best two scores, the average of the best two scores, and the letter grade
corresponding to the average. In other words, Professor Nutty will drop the
lowest exam score. The exam scores are not sorted in the input file.
Your program will prompt the user for the name of the input file and
read the data from it. Your program will generate a report showing the
ID#, the best two scores, the average of the best two scores and letter grade
corresponding to the average. The report will be stored in an output text
file whose name the user will be prompted to enter.
A modular implementation must be designed using functions. In addition
to the main function, your program will consist of the following user-defined
functions; you may design more:
/**
* sorts three numbers in ascending order. After
* this function is executed, smallest will be the
* smallest number, median, the median value, and
* largest the largest.
* @param smallest a non-negative fixed-point value
* @param median a non-negative fixed-point value
* @param largest a non-negative fixed-point value
*/
void sort3(double &smallest, double &median, double &largest)
/**
* computes the average of two numbers
* @param num1 a non-negative number
* @param num2 a non-negative number
* @return the average of num1 and num2
*/
double averageOf2(double num1, double num2)
/**
* computes the corresponding letter grades for a number
* @param score a non-negative number less than or equals to 100
* @return A <- 90<=score<=100; B <- 80<=score<90; C <- 70<=score<80;
* D <- 60<=score<70; F <- 0<=score<60.
*/
char calcGrade(double score)
All other tasks not performed by a sub-function should be performed by the
main functions: these tasks include opening the input and output files as
well as file input/output operations.
Your program should prompt the user for the name of the input and out-
put files. Be sure to perform error-check on both files to determine whether
the input file is successfully opened and whether the output file is successfully
created. Your program should then generate a report following the format
below. Ensure that numeric values in the report are formatted so that they
have the same number of decimal places as shown in the sample output be-
low. Once the data from the input file have been processed, close the file.
Also, close the output file before the program terminates.
For a sample input file, ence7010f11.grd, with the data below:
2008-EN-001 95 80 100
2009-NE-095 60 98 97.5
2011-PA-158 80 70 50
A typical program interaction would be:
Enter the name of the data file> ence7010f11.grd
Enter the name of the output file> ence7010f11.rpt
Here is the contents of the sample output file (ence7010f11.rpt):
Encephalopathy (Med-7010)
Final Course Report
Fall 2011
================================================
ID# Score Score Average Grade
2008-EN-001 95.00% 100.00% 97.500% A
2009-NE-095 97.50% 98.00% 97.750% A
2011-PA-158 70.00% 80.00% 75.000% C
------------------------------------------------
*** END OF REPORT ***
================================================