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). You will have to decide as to what arguments must be passed to the functions and whether such passing must be by value or by reference or a mixture of both.
1. Void greeting()
The function greeting () generates generalized greeting and outputs to the output file as the first message.
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 etx.)
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.
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 student.
5. Double calculateAverage()
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 Lab5.
7. Void printData()
The function printData() prints the student name, their overall average and their grade to the output file.
8. Void farewell()
The 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.
The pseudo code for the main function is given below
Declare necessary variables
Prompt user to supply the input file name
Open the input file
If input file does not exist then inform user and exit the program
Else
Prompt user to supply the output file name
Open the output file
If the output file does not exist then inform user and exit the program
Else
Call function greeting()
Call function getName() to read the first name from the input
File
While not end of input file
Call function ReadScore()
If no valid scores then
Call function reportNoScore()
Else
Call function calculateAverage()
Call function assignGrade()
Call function printData()
Call function getName()
End of loop
Call function farewell () to print the farewell message in the data file.
Close the input file.
Close the output file.
End of main
This is not a homework site. We won't do your homework for you. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.
We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again. As it is impossible to find derivative of function without knowledge in arithmetics, you cannot do more complex tasks in programming without clear understanding of basics