Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that reads GPA scores from a file called studentData.txt and displays a menu asking the user to choose a, b, or c.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Write a program that reads GPA scores from a file called "studentData.txt" and displays a menu asking the user to choose a, b, or c. In addition, the user also has to option to quit by choosing d. As long as the user does not choose to quit, the program loops over displaying the menu. Your program must also do input validation and print an error message if the user types anything other than a, b, c, or d, then display the menu again and ask the user to reenter the user's choice. a) The number of scores in the file b) The sum of all the scores in the file c) The average of all scores in the file d) Quit If the user chooses a), b), or c), your program should print the result on the screen (cout) "studentData.txt" file can be downloaded from eLearning. Use that file to test your code, but your code must work for any file which contains GPA scores, where the number of GPA scores is arbitra 1. Additional requirements-Make sure you meet all the requirements to avoid losing points 1. To complete the assignment, you are required to use only what has been taught in class. If you 2. 3. 4. have prior programming experience, refrain from using more advanced C++ constructs, so all the homework programs can be graded on a consistent basis. Make sure you follow the requirements in the "Homework Notes". You are allowed to hard code the file name in your program. You are required to implement the following functions getUserChoice: displays the menu, prompts the user to enter the choice, performs input validation, displays the menu again if the input is invalid. Returns the user's choice if it is valid calcNumber: open the file (checks for file open failure and exit the program if there is failure), read the data, calculate the number of values in the file, then close the file,and returns the result. calcSum: open the file (checks for file open failure and exit the program if there is failure), read the data, calculate the sum of values in the file, then close the file, and returns the result. calcAvg: open the file (checks for file open failure and exit the program if there is failure), read the data, calculate the average of values in the file, then close the file,and returns the result *

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How can you influence the powers that be to make changes?

Answered: 1 week ago