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();
}