Question
Assignment description: Write a C++ program that opens the file infile.txt and reads the numbers in the file. The user should see a menu with
Assignment description: Write a C++ program that opens the file infile.txt and reads the numbers in the file. The user should see a menu with choices to see the total, the average, the count, or the option to quit. Accept only choices 1-4 for the menu input using a do-while loop. Use a switch statement to calculate and display the sum, average, or count, or "We are done."
Sample output:
This program uses the numbers in the infile.txt file.
What would you like to know?.
1. Sum of the numbers
2. Average of the numbers
3. How many numbers there are
4. Quit
Your choice: 1
Total sum is :623988
Press any key to continue . . .
This program uses the numbers in the infile.txt file.
What would you like to know?.
1. Sum of the numbers
2. Average of the numbers
3. How many numbers there are
4. Quit
Your choice: 2
Average of the numbers is: 4991.9
Press any key to continue . . .
This program uses the numbers in the infile.txt file.
What would you like to know?.
1. Sum of the numbers
2. Average of the numbers
3. How many numbers there are
4. Quit
Your choice: 3
Count of the numbers is: 125
Press any key to continue . . .
This program uses the numbers in the infile.txt file.
What would you like to know?.
1. Sum of the numbers
2. Average of the numbers
3. How many numbers there are
4. Quit
Your choice: 4
We are done.
Press any key to continue . . .
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