So, my program uses a while loop to fill two separate vectors by asking the name of an item (vector one) then asking the price of the item (vector two).
double ItemCost;
vector<double> Cost;
string ItemName;
vector<string> Item;
while (ItemName != "done")
{
cout << "Item name: "; cin >> ItemName;
Item.push_back(ItemName);// gets item name from use and stores in the vector "Item"
if (ItemName != "done")
{
cout << "Item cost: $"; cin >> ItemCost;
Cost.push_back(ItemCost);// gets cost of item and stores it in the vector "cost"
}
else
{
continue;
}
}
system("CLS");
So after the clear screen, I would like the program to output a screen that shows the item name, then to the right it's cost. Then on the next line the same thing for the 2nd item input. Essentially like this would display:
cout << Item[0]; cout << " $" << Cost[0];
cout << Item[1]; cout << " $" << Cost[1] << endl;
cout << Item[2]; cout << " $" << Cost[2] << endl;
But, I want it to do this no matter how many items are input, also doing it the way I did above is obviously a bad Idea if they input less then the amount I have in the code, because the program will try to reach outside the vectors occupied memory ect. That was just to give an example of the format I'm going for.