Can anyone give a solution for this? Im just new here.
Wishing to have a great time here :)

by the way :

I made a program that the user will buy a certain product (a cake) then i also have a "receipt-like" after. But i dont know how to put all (or list) the products that the user have chosen included with the price.

Here is my code:

#include<iostream>
using namespace std;
int main()
{
   
int order=0,quantity,cake;
float payable=0,cash,price,change,total1;
char pitz;
system ("color F2");




    cout<<"\t\t\tWelcome to Rigz Cakes and Pastries\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: Chocolate cake."<<endl;
                cout<<"\tPrice: P";
                                cin>>price;
                if ((price<240)||(price>240)) {
                char a;
                cout<<"\a\n\n\n      WARNING: Please enter the right price, the security is watching over you.";
                cout<<"\n\n\tWould you like to reset the program to choose order again? (Y or N): ";
                cin>>a;
                system("cls");
                if((a=='Y')||(a=='y'))  {
                WinExec("program menu.exe", SW_SHOW);
                exit(1);
                } else {
                return(0);
                }
                }
                cout<<"\tHow many: ";
                                cin>>order;
                total1=price*order;
                cout<<"\tTotal: P"<<total1<<endl;
                break;                      
        case 2:
                cout<<"\n\tYou ordered for: Cheese cake."<<endl;
                cout<<"\tPrice: P";
                                cin>>price;
                if ((price<230)||(price>230)) {
                char b;
                cout<<"\a\n\n\n      WARNING: Please enter the right price, the security is watching over you.";
                cout<<"\n\n\tWould you like to reset the program to choose order again? (Y or N): ";
                cin>>b;
                system("cls");
                if((b=='Y')||(b=='y'))  {
                WinExec("program menu.exe", SW_SHOW);
                exit(1);
                } else {
                return(0);
                }
                }
                cout<<"\tHow many: ";
                                cin>>order;
                total1=price*order;
                cout<<"\tTotal: P"<<total1<<endl;
                break;
        case 3:
                cout<<"\n\tYou ordered for: Pandan cake."<<endl;
                cout<<"\tPrice: P";
                                cin>>price;
                if ((price<270)||(price>270)) {
                char c;
                cout<<"\a\n\n\n      WARNING: Please enter the right price, the security is watching over you.";
                cout<<"\n\n\tWould you like to reset the program to choose order again? (Y or N): ";
                cin>>c;
                system("cls");
                if((c=='Y')||(c=='y'))  {
                WinExec("program menu.exe", SW_SHOW);
                exit(1);
                } else {
                return(0);
                }
                }
                cout<<"\tHow many: ";
                                cin>>order;
                total1=price*order;
                cout<<"\tTotal: P"<<total1<<endl;
                break;
        case 4:
                cout<<"\n\tYou ordered for: Fruit cake."<<endl;
                cout<<"\tPrice: P";
                                cin>>price;
                if ((price<300)||(price>300)) {
                char d;
                cout<<"\a\n\n\n      WARNING: Please enter the right price, the security is watching over you.";
                cout<<"\n\n\tWould you like to reset the program to choose order again? (Y or N): ";
                cin>>d;
                system("cls");
                if((d=='Y')||(d=='y'))  {
                WinExec("program menu.exe", SW_SHOW);
                exit(1);
                } else {
                return(0);
                }
                }
                cout<<"\tHow many: ";
                                cin>>order;
                total1=price*order;
                cout<<"\tTotal: P"<<total1<<endl;              
                break;
        case 5:
                cout<<"\n\tYou ordered for: Banana cake."<<endl;
                cout<<"\tPrice: P";
                                cin>>price;
                if ((price<220)||(price>220)) {
                char e;
                cout<<"\a\n\n\n      WARNING: Please enter the right price, the security is watching over you.";
                cout<<"\n\n\tWould you like to reset the program to choose order again? (Y or N): ";
                cin>>e;
                system("cls");
                if((e=='Y')||(e=='y'))  {
                WinExec("program menu.exe", SW_SHOW);
                exit(1);
                } else {
                return(0);
                }
                }
                cout<<"\tHow many: ";
                                cin>>order;
                total1=price*order;
                cout<<"\tTotal: P"<<total1<<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("program menu.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;
                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<<"\n\n\t\t\tO F F I C I A L    R E C E I P T"<<endl;
        cout<<"\n\t\t\t     Rigz Cakes and Pastries ";
        cout<<endl;
        cout<<endl;
        cout<<endl;
        cout<<endl;
        
        
        cout<<"\n\tYou ordered for number: "<<cake;
        
        switch (cake) {
        
                case 1:
        cout<<") Chocolate cake";
                break;
                case 2:
        cout<<") Cheese cake";
                break;
                case 3:
        cout<<") Pandan cake";
                break;
                case 4:
        cout<<") Fruit cake";
                break;
                case 5:
        cout<<") Banana cake";
                break;
         }
         
                
        cout<<"..... P"<<price<<endl;
        quantity=order+order;
        cout<<"\n\tTotal quantity: "<<quantity<<endl;
        cout<<"\n\tTotal: P"<<payable<<endl;
        cout<<"\n\tCash: P"<<cash<<endl;
        cout<<"\n\tChange: P"<<change<<endl;
        cout<<"\a\n\n\t\t\t   Thank you,please come again!";
        cout <<"\n\n\tTime: "<<__TIME__;
        cout<<"\t\t\t\tCreated by: Rigor N. Cadiz";
        cout<<"\n\tDate: "<<__DATE__<<endl;
        
        
	
 
getchar();
cin.get();

}

U might wanna fix your reset.. because it definitely doesn't re-open the program or reset it.. it just exits.. anyway I fixed the quantity problem for u.. I just added variables at the top such as:

choc, cheese, pandan, fruit, banana and set them all to zero.. then I added after the total calculation:
choc += order; aka choc = choc + order.. same thing..
cheese += order;
etc..

then u just make quantity = choc + cheese + pandan + fruit + banana;
and whala.. remove your case statements and put if's without the else's.. and bam.. good to go.

P.S. A case statement is like a lot of if-else statements.. just more simple.. when you do that, it goes if this.. then cout choc cake.. else cout cheese else blah blah.. it doesn't do them all.. so you have to remove the else's so it goes if this cout choc cake.. if that cout cheese and blah blah.. that way it prints everything rather than only one! That's why we got rid of the case statements.

#include <iostream>
#include <windows.h>

using namespace std;
int main()
{

int order=0,quantity,cake;
float payable=0,cash,price,change,total1;
char pitz;

Edited 3 Years Ago by happygeek: fixed formatting

U might wanna fix your reset.. because it definitely doesn't re-open the program or reset it.. it just exits.. anyway I fixed the quantity problem for u.. I just added variables at the top such as:

choc, cheese, pandan, fruit, banana and set them all to zero.. then I added after the total calculation:
choc += order; aka choc = choc + order.. same thing..
cheese += order;
etc..

then u just make quantity = choc + cheese + pandan + fruit + banana;
and whala.. remove your case statements and put if's without the else's.. and bam.. good to go.

P.S. A case statement is like a lot of if-else statements.. just more simple.. when you do that, it goes if this.. then cout choc cake.. else cout cheese else blah blah.. it doesn't do them all.. so you have to remove the else's so it goes if this cout choc cake.. if that cout cheese and blah blah.. that way it prints everything rather than only one! That's why we got rid of the case statements.

#include <iostream>
#include <windows.h>

using namespace std;
int main()
{

int order=0,quantity,cake;
float payable=0,cash,price,change,total1;
char pitz;

end quote.

What do you mean it doesnt reopen? in what part?..Well it functions in my compiler Dev C++ sir, and sorry for very long codes. Im just a beginner..and other ideas like the "reset", and the system color is learned from the net. If you dont mind can you post a correction for the said error?. And the receipt part. Thanks anyways.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

by the way the total quantity is not my problem but, how can i list all the input from the user. (i.e the user choose the Chocolate cake and Cheese cake) how could i make it appear in the Receipt? :

You ordered for number/s: 1) Chocolate cake
2) Cheese cake


any codes that i could use like loops or jump statements??

I dont know what really the term for that .

hey. can i ask? how does that program.exe work? if you wont mind. thanks!

program.exe is the name of my compiled program which is the address to restart it. Which is in the 'if' is == 'n' ..my program.exe (which is my program) will restart.

This article has been dead for over six months. Start a new discussion instead.