Question: I am still getting a few errors in my code. Can you help? #include #include using namespace std; double getListAverage ( const vector &values )
I am still getting a few errors in my code. Can you help?
#include
#include
using namespace std;
double getListAverageconst vector &values
double sum ;
for const auto &value: values
sum value;
return sum values.size;
void extractSmallValuesconst vector &valueList, double average, vector &smallList
for const auto &value : valueList
if value average
smallList.pushbackvalue;
void extractLargeValuesconst vector &valueList, double average, vector &largeList
for const auto &value : valueList
if value average
largeList.pushbackvalue;
int main
double inputValue;
vector valueList;
double average;
vector smallList;
vector largeList;
Assume the user will enter a number, but make sure
the number is greater than
TODO: Capture user input.
cout "Enter a Number Greater Than : ;
cin inputValue;
while inputValue
cout "Try Again! Enter a number greater than : ;
cin inputValue;
valueList.pushbackinputValue;
Get Average
average getListAveragevalueList;
Get small values
TODO: Call function to get small values
extractSmallValuesvalueList average, smallList;
Get large values
TODO: Call function to get large values
extractLargeValuesvalueList average, largeList;
cout endl "Average: average endl;
Print small values
cout endl "Small Values: ;
TODO: Print small values
forconst auto &value : smallList
cout value ;
cout endl "Large Values: ;
TODO: Print large values
forconst auto &value : largeList
cout endl ;
cout endl;
return ;
Function name: getListAverage
Has one value parameter: a list of doubles
Function computes average of numbers in list.
Function returns average.
double getListAveragevector list
double average ;
if listsize
return ;
for int i ; i list.size; i
average listi;
return average list.size;
Function name: extractSmallValues
Has two value parameters and one reference: a list of doubles and an average
and a smallList that will represent the numbers in the list that are smaller
than the average.
Function finds numbers in list that are smaller than average and stores
them in smallList
Function doesn't return anything.
TODO: write function
void extractLargeValues const vector &valueList, double average, vector &largeList
for const auto &value : valueList
if value average
largeList.pushbackvalue;
Function name: extractLargeValues
Has two value parameters: a list of doubles and an average
Function finds numbers in list that are greater than average
stores them in a new listvector as integers.
Function returns new listvector of integers.
TODO: write function
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
