Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This program is to be written to accomplish same objectives, as did the program Except this time we modularize our program by writing functions, instead
This program is to be written to accomplish same objectives, as did the program Except this time we modularize our program by writing functions, instead of writing the entire code in main. The program must have the following functions (names and purposes given below) datrereadnamasfie You will have to decide as to what arguments must be passed to the functions and whether sueh passing must be by value or by reference or a mixture of both. Declare necessary variables Prompt user to supply the input file name Open the input file Ifinput file does ot exist then inform userand exit the progrm Else Prompt user to supply the output file name Open the output fTle 1. void greeting) The function greeting ) generates generalized greeting and outputs to the output ile as the first message. If the output file does not exist then inform user and exit the program Else Call function greeting) Call fanction getName( to read the first name from the input Mle 2. void getName ) The function reads the name of the student from the data file and processes the name as needed. (For example for outputting etc.), While not end of input file Call function ReadScore ) If no valid scores thern Call function reportNoScore () 3. void readScore ) The function reads and sums the student scores and keeps track of number of scores read. Both the sum of scores and number of scores read are returned by reference. Else Call function calculateAverage () Call funerion assignGrade () Call function printData () 4 void reportNoScore () If the file has no scores for a student, the function generates a message printing student name and the fact that there are no scores found for that student. Call function getName) End of loop Call function farewell Close the input file Close the output ilk End of main to print the farewell message in the data filc. 5. double ealculateAverage) The function take the sum of all scores and as to how many scores were read and returns the average score. 6. char assignGrade () The function takes the average score calculated by function calculateAverage () and returns a letter grade, using the same criterion as used in Lab 5. 7. void printData ) The function printData ) prints the student name, their overall average and their grade to the output file 8. void farewell) he program prints the farewell message in the output file, signifying the end of program The approximate pseudo code for main function is given on next page. do ende for the main function is given below
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started