Question: Write a C++ program to prompt user for a file name open it and determine how many people are 25 years old in the file
Write a C++ program to prompt user for a file name open it and determine how many people are 25 years old in the file contain name and ages of people, also find and print the average of the ages in the file. Print the results using iomanip commands. Assume the file has a series of integer numbers and name separated by new line.
If the file does not exit, print the following message and terminate the program: Bad file name. If the file does not have any data in it, print the following message and terminate the program: No data in the file, program terminated.
Sample Input File:
25 Joe Smith 32 Adam Haily
Sample output:
Average Age: xx.xx // print the actual value with 2 digits precision Number of 25 year olds : xx // print the actual number
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
