I have a program that takes in 10 "purchase prices" from a user and displays them in the console screen. I am attempting to modify the code to make it to where the user can determine how many inputs they like for "purchase prices" and then displays that amount of them on the console screen.
The current modification i was successful in was changing was the for loop inside the vector from for "(int i = 0; i < 10; i++)" to "for (int i = 0; i < purchases.size(); i++)" but from here I am stuck.
It seems that I may need some function or loop prior to the vector declaration to set the size variable based on user entries possibly but I am not sure. Thank you for you help-
My code:
vector<double> purchases(10);
{
for (int i = 0; i < purchases.size(); i++)
{
cout << "Enter a purchase amount: ";
cin >> purchases[i];
}
cout << "The purchase amounts are: " << endl;
for (int i = 0; i < 10; i++)
{
cout << purchases[i] << endl;
}
}
system("PAUSE");
return (0);
}
resize()method.push_back.emplace_back, orinsert