Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using C++ Please write a program to read 10 grades from a file and display the average. This will include the functions getFileName ), displayAverage
Using C++
Please write a program to read 10 grades from a file and display the average. This will include the functions getFileName ), displayAverage and readFile(): main leNameaverag getFileName readFile display getFilename () This function will prompt the user for the name of the file and return it. The prototype is: void getFileName (char fileName []); Note that we don't return text the way we do integers or floats. Instead, we pass it as a parameter. We will learn more how this works in Section 3 readFile ) This function will read the file and return the average score of the ten values. The prototype is: float readFile (char fileName []) Hint: make sure you only read ten values. If there are more or less in the file, then the function must report an error. Display the following message if there is a problem with the file: Error reading file "grades.txt" display ) This function will display the average score to zero decimals of accuracy (rounded). The prototypee is: void display (float average); Example Consider a file called grades.txt (which you can create with emacs) that has the following data in it: 90 86 95 76 92 83 100 87 91 88 When the program is executed, then the following output is displayed: Please enter the filename: grades.txt Average Grade: 89%Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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