Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program named intavg.cpp that implements the list using a vector . In a loop, ask the user for integers If the user enters
Write a program named intavg.cpp that implements the list using a vector . In a loop, ask the user for integers If the user enters -l, end user input Use an input validation loop to make sure the user input is 2 or greater Append the validated integer to the vector Use the push back() vector member function Calculate and display the resulting arithmetic mean (average) of the vector WITH the new integer Use the size member function If the mean is NOT a whole number Display a message rejecting the integer and remove the integer from the vector . Use the pop back() member function If the mean is a whole number: Display a message accepting the integer and keep the integer in the vector . Once the user is done (user enters-I), calculate and display the mean of the first one element, first two clements, and so on, until the mean of the entire vector is calculated and displayed Each mean should be a whole number Task 1 Sample Output Please enter an integer (2 or greater, -1 to finish): 14 That is not a valid number! Please try again. Please enter an integer 2 or greater, -1 to finish): 2 The new arithmetie maan is 2 Your input has been accepted! Please enter an integer 2 or greater, -1 to finish): 34 The new arithmeti mean is 2.5 SOETY, your input was rejected and will be removed! -1 to finish): 4. Please enter an integer 2 or greater The new arithmetic meanis 3 Your input has been accepted! 1 to finish) 6. Please enter an integer 12 or greater, The new arithmetic mean ist Your input has been accepted! Please enter an integer 2 or greater -1 to finish) 74 The Dav arithmetie mean is 4.75 SCETYYour input was rejected and will be removed 1 to finish Please enter an integer 12 or greater The Dav arithmetie man is 5 Your input has been accepted! Please enter an integer 2 or greater 1 to finish) -1. Vector Elements berat 31- Mean of the first 1 element is): 2 Mean ot the first 2 element is) 3 Meanot the first elementis 4 Mean of the first 4 element is) 5
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