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 getListAverage(const vector &values){
double sum =0;
for (const auto &value: values){
sum += value;
}
return sum / values.size();
}
void extractSmallValues(const vector &valueList, double average, vector &smallList){
for (const auto &value : valueList){
if (value < average){
smallList.push_back(value);
}
}
}
void extractLargeValues(const vector &valueList, double average, vector &largeList){
for (const auto &value : valueList){
if (value > average){
largeList.push_back(value);
}
}
}
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 -1
// TODO: Capture user input.
cout << "Enter a Number Greater Than -1: ";
cin >> inputValue;
while (inputValue <=-1){
cout << "Try Again! Enter a number greater than -1: ";
cin >> inputValue;
}
valueList.push_back(inputValue);
// Get Average
average = getListAverage(valueList);
// Get small values
// TODO: Call function to get small values
extractSmallValues(valueList, average, smallList);
// Get large values
// TODO: Call function to get large values
extractLargeValues(valueList, average, largeList);
cout << endl << "Average: "<< average << endl;
// Print small values
cout << endl << "Small Values: ";
// TODO: Print small values
for(const auto &value : smallList){
cout << value <<"";
}
cout << endl << "Large Values: ";
// TODO: Print large values
for(const auto &value : largeList){
cout << endl <<"";
}
cout << endl;
return 0;
}
//////////////////////////////////
// Function name: getListAverage
// Has one value parameter: a list of doubles
//
// Function computes average of numbers in list.
//
// Function returns average.
//////////////////////////////////
double getListAverage(vector list){
double average =0;
if (list.size()==0){
return 0.0;
}
for (int i =0; i < list.size(); i++){
average += list[i];
}
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.push_back(value);
//}
//}
//}
//////////////////////////////////
// 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 list/vector as integers.
//
// Function returns new list/vector of integers.
//////////////////////////////////
// TODO: write function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!