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 -1,
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 -1, 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 o Use the push_back() vector member function Calculate and display the resulting arithmetic mean (average) of the vector WITH the new integer o Use the size () member function If the mean is NOT a whole number. O 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. o Display a message accepting the integer and keep the integer in the vector . Once the user is done (user enters -1), calculate and display the mean of the first one element, first two elements, 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 O greater, -l to finish): 2 The new arithmetic mean is 2 Your input has been accepted! Please enter an integer (2 Or greater, -l to finish): 3 The new arithmetic mean is 2.5 Sorry, your input was rejected and will be removed! Please enter an integer (2 or greater, -l to finish): 4 The new arithmetic mean is 3 Your input has been accepted! Please enter an integer (2 or greater, -1 to finish): 5 The new arithmetic mean is 4 Your input has been accepted! Please enter an integer (2 or greater, -l to finish): 74 The new arithmetic mean is 4.75 Sorry, your input was rejected and will be removed! Please enter an integer (2 or greater, -1 to finish): 8. The new arithmetic mean is 5 Your input has been accepted
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