Can anyone help me with this:
I made a program where the user will choose a product from a menu and i want after the products that the user chosen will be output also below where there is like a "receipt-like" or a summary of what the user bought. I have another post with this code but it seems that the title before was not appropriate. Im out of idea.

#include<iostream>
#include<windows.h>
using namespace std;
int main()
{

char *kinds[5] = {" Chocolate Cake"," Cheese Cake"," Pandan Cake"," Fruit Cake"," Banana Cake"},pitz; 
int order1=0,order2=0,order3=0,order4=0,order5=0,quantity,cake,chocake=240,checake=230,pandcake=270,fruicake=300,banacake=220;
float payable=0,cash,price,change,total1=0,total2=0,total3=0,total4=0,total5=0,sum = 0,n; 

system ("color F2");




    cout<<"\a\t\t\t     -Welcome to Rigz Cakeshop-\n"<<endl;
    cout<<"\tPlease choose your order: "<<endl;
    cout<<"\n\t\t 1)Chocolate Cake                     P240.00";
    cout<<"\n\t\t 2)Cheese Cake                        P230.00";
    cout<<"\n\t\t 3)Pandan Cake                        P270.00";
    cout<<"\n\t\t 4)Fruit Cake                         P300.00";
    cout<<"\n\t\t 5)Banana Cake                        P220.00";
    cout<<endl;
  
              
  do {
      cout<<"\n\t\t Please choose your order from the list: ";
                cin>>cake;   
      payable=payable+total1;
  

      
switch (cake) {

        case 1:
                cout<<"\n\tYou ordered for:"<<kinds[0]<<endl;
                cout<<"\tPrice: P"<<chocake<<endl;
                cout<<"\tHow many: ";
                                cin>>order1;
                total1=chocake*order1;
                cout<<"\tTotal: P"<<total1<<endl;
                break;                      
        case 2:
                cout<<"\n\tYou ordered for:"<<kinds[1]<<endl;
                cout<<"\tPrice: P"<<checake<<endl;
                cout<<"\tHow many: ";
                                cin>>order2;
                total2=checake*order2;
                cout<<"\tTotal: P"<<total2<<endl;
                break;
        case 3:
                cout<<"\n\tYou ordered for:"<<kinds[2]<<endl;
                cout<<"\tPrice: P"<<pandcake<<endl;
                cout<<"\tHow many: ";
                                cin>>order3;
                total3=pandcake*order3;
                cout<<"\tTotal: P"<<total3<<endl;
                break;
        case 4:
                cout<<"\n\tYou ordered for:"<<kinds[3]<<endl;
                cout<<"\tPrice: P"<<fruicake<<endl;
                cout<<"\tHow many: ";
                                cin>>order4;
                total4=fruicake*order4;
                cout<<"\tTotal: P"<<total4<<endl;              
                break;
        case 5:
                cout<<"\n\tYou ordered for:"<<kinds[4]<<endl;
                cout<<"\tPrice: P"<<banacake<<endl;
                cout<<"\tHow many: ";
                                cin>>order5;
                total5=banacake*order5;
                cout<<"\tTotal: P"<<total5<<endl;
                break;
        default:
                cout<<"\a\n\n\t\t\tSorry it is not available here."<<endl<<endl;
                char f;
                cout<<"\tWould you like to reset the program to choose order again? (Y or N): ";
                cin>>f;
                system("cls");
                if((f=='Y')||(f=='y'))  {
                WinExec("a-piece-of-cake.exe", SW_SHOW);
                exit(1);
                } else {
                return(0);
                }
                break;
                
                }
                cout << "\n\t\t\tDo you want to order another (y/n)? ";
                		                cin >> pitz;
				                }
                while ((pitz == 'y')||(pitz == 'Y'));

                payable=payable+total1+total2+total3+total4+total5;
                cout<<"\n\tAmount to be paid: P"<<payable;
        
        do {
                cout<<"\n\tYour cash is: P";
                        cin>>cash;
        if (cash<payable){
                cout<<"\a\n\t\t\t     Your money is not enough. "<<endl;
                                }
           }
           
        while (cash<payable);
        
        change=cash-payable;
        cout<<"\n\tYour change is: P"<<change<<"\n\n"<<endl<<endl;
        
        cout<<"\t\t  For your receipt: ";
        system("pause");
        system("cls");
        system("color E0");
        
        
        
        
        
        
        
        cout<<"\t\t\t O F F I C I A L    R E C E I P T"<<endl;
        cout<<"\n\t\t\t         -Rigz Cakeshop-\n";
        
        
        cout<<"\n\tYou ordered for numbers: ";

        quantity=order1+order2+order3+order4+order5;
        cout<<"\n\tTotal quantity: "<<quantity;
        cout<<"\t\t\t\t    Cash: P"<<cash;
        cout<<"\n\tTotal: P"<<payable;
        cout<<"\t\t\t\t\t    Change: P"<<change;
        cout<<"\a\n\t\t\t    Thank you,please come again!"<<endl;
        cout<<"\n\tAlso try our other cakes. "<<endl;
        cout<<"\n\t\t 1)Chocolate Cake                     P240.00";
        cout<<"\n\t\t 2)Cheese Cake                        P230.00";
        cout<<"\n\t\t 3)Pandan Cake                        P270.00";
        cout<<"\n\t\t 4)Fruit Cake                         P300.00";
        cout<<"\n\t\t 5)Banana Cake                        P220.00"<<endl;
        cout<<"\n\n\t*We accept all kinds of occasions"<<endl;
        cout<<"\tFor *orders *comments or *suggestions please contact: 09169475449"<<endl;
        cout<<"\tEmail @: rigorcadiz@yahoo.com"<<endl;
        cout <<"\n\tTime: "<<__TIME__;
        cout<<"\t\t\t\tCreated by: Rigor N. Cadiz";
        cout<<"\n\tDate: "<<__DATE__<<endl;
        
        
	
 
getchar();
cin.get();

}

The best way to seek help is to come with code (which you have done) and have specific questions about particular sections of it. Saying "I need to add a receipt portion" dumps the responsibility into our lap.

The first thing you don't need are these WinExec statements. You have some loop structure in there, so employ it when you need to send the user through the code for another round.

There's a pattern in your case statements. They are all doing the same thing short of the cake type being different. Make one statement that outputs the type of cake and then leads the user through the prompts. Get rid of that switch entirely.

The key to being able to do the receipt is keeping track of what the user has purchased. Hint, use an array of fixed size to hold the numbers of the items the user orders (and the total number they have ordered), then dump out the array and use kinds to label the output.

Get small pieces of it working before you try to plow through the whole thing at once, it will make your life much easier.

Yah that is the good thing about it but im just a beginner :) and those WinExec were just explored through net..Anyone suggestions?

Yah that is the good thing about it but im just a beginner :) and those WinExec were just explored through net..Anyone suggestions?

Whatever website told you WinExec was a good idea, please burn it in a fire :)

Use a loop like jonsca suggested with a conditional to set whether or not to repeat said loop.

bool keep_running = true;
while (keep_running) {
    // do program stuff
    // prompt whether to keep running
    // handle response
}
return 0;

Hi Dani,
Can you please help me write a C++ Program that Prompt Receipts

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.