Question: Integer numValues is read from input. Then numValues doubles are read and stored in vector inventoriesList. Write a loop that outputs each element in inventoriesList

Integer numValues is read from input. Then numValues doubles are read and stored in vector inventoriesList. Write a loop that outputs each element in inventoriesList that is greater than 1500.0, and assigns the element with 1500.0. End each output with ": corrected to 1500.0" followed by a newline.

Ex: If the input is 3 1366.0 2166.0 85.0, then the output is:

Raw inventories: 1366.0

2166.0 85.0 2166.0: corrected to 1500.0

Adjusted inventories: 1366.0 1500.0 85.0

#include #include #include using namespace std;

int main() { int numValues; unsigned int i; vector inventoriesList; cin >> numValues; inventoriesList.resize(numValues); for (i = 0; i < inventoriesList.size(); ++i) { cin >> inventoriesList.at(i); } cout << fixed << setprecision(1) << "Raw inventories: "; for (i = 0; i < inventoriesList.size(); ++i) { cout << inventoriesList.at(i) << " "; } cout << endl;

/* Your code goes here */

cout << "Adjusted inventories: "; for (i = 0; i < inventoriesList.size(); ++i) { cout << inventoriesList.at(i) << " "; } cout << endl; return 0; }

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 Databases Questions!