Help with allowing more than one item on a recipt

I have been trying to create a program that allows me to add more than one thing to a recipt. The code i have now is...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    do
    {
      cout<<"Enter in the item name\n";
      cin>>item_name;
      cout<<"Enter in the price of the item\n";
      cin>>item_price;
      cout<<"Enter the item quantity\n";
      cin>>item_quant;
      system("cls");
      item_total = (item_quant*item_price) + item_total;
      cout<<"\n\n\n"<<setw(20)<<"Item Name"<<setw(20)<<"Item Quantity"<<setw(20)<<"Item Price"<<setw(20)<<"Item Total\n\n";
      cout<<setw(20)<<item_name<<setw(20)<<item_quant<<setiosflags(ios::fixed)<<setprecision(2)<<setw(20)<<item_price<<setw(18)<<item_total;
      cout<<"\n\n\n\n\n\n\n";
      cout<<setw(60)<<"Item Total"<<setw(10)<<item_total;
      cout<<"\n";
      cout<<setw(60)<<"Tax Total"<<setw(10)<<(item_total * .06);
      cout<<"\n";
      cout<<setw(60)<<"Total"<<setw(10)<<((item_total * .06) + item_total);
      cout<<"\n";
      system("pause");
      system("cls");
      cout<<"Is there another item to scan?\n";
      cout<<"((1)) Yes\n";
      cout<<"((Any other number)) No\n";
      cin>>scan_again;
      }
    while (scan_again == 1);
    system("PAUSE");
    return EXIT_SUCCESS;

The code that i have now only allows for one item to be shown at a time.
What I would do is make a struct for each item and then create a vector of the items. Just use push_back near the end of the while loop to add the item to the vector.
For the same U need an container to store the same and after all input U can display all the items at a time.
They are talking about something like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
struct Item {
 string name;
 float price;
 int quantity;
};

int main() {

 vector<Item> vItemList;

 Item myItem1;
 myItem.name = "Coke";
 myItem.price = 1.80f;
 myItem.quantity = 3;

 vItemList.push_back(myItem1);

 Item myItem2; // Etc

 // Now To Print
vector<Item>::iterator vPtr = vItemList.begin();
 while (vPtr != vItemList.end()) {
   cout << "Item: " << (*vPtr).name << endl;
   cout << "Qty: " << (*vPtr).quantity << endl;
   cout << "SubTotal" << ( (*vPtr).price * (*vPtr).quantity ) << endl;
   vPtr++;
 }
 // etc

}
By item do you mean something like "Total", or "Item Tax"? Or do you mean one actual grocery or whatever it may be? More than one grocery won't show because you have a system("cls") in your loop.
Ok, thanks for the help. The code seems to work fine. See ya, and thanks again.
Topic archived. No new replies allowed.