Hi! Guys Im a computer science student in Philippines i have problem making this program. My Professor said that i will make a Restaurant Menu program and every time that i press (Y) it will loop in the 1st menu and order again in the sub menu. The problem is that if i press (N) all of the order will add and minus to my cash. Heres what you should do when i press (N) all order should be add on how many times i buy and ask only 1 time if how much is my cash.
#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
char y;
do
{clrscr();
cout<<"\t\t\tJayson`s Restaurant\n\n";
cout<<"MENU:\n\n";
cout<<"a.Desserts\nb.Foods\nc.Drinks\nd.Exit\n\n";
cin>>y;
switch(y)
{
case 'a':
clrscr();
int i,x,c;
char m;
cout<<"Press the number of the Desserts you like:\n\n";
cout<<"1.Fruit Salad . . . . . . .P300\n2.Vegetable Salad . . . . . . .P250\n3.Ice Cream . . . . . . .P280\n\n";
cin>>x;
if(x==1)
{clrscr();
cout<<"Your Balance is:P300";
cout<<"\n\nEnter the amountof your cash:";
cin>>c;
if(c>=300)
{clrscr();
i=c-300;
cout<<"Your change is:P"<<i;
}
else
{clrscr();
cout<<"The amount you entered is insufficient";
}
}
else if (x==2)
{clrscr();
cout<<"Your Balance is:P250";
cout<<"\n\nEnter the amount of your cash:";
cin>>c;
if(c>=250)
{clrscr();
i=c-250;
cout<<"Your change is:P"<<i;}
else
{clrscr();
cout<<"The amount you entered is insufficient";}
}
else if(x==3)
{clrscr();
cout<<"Your Balance is: P280";
cout<<"\n\nEnter the amount of your cash:";
cin>>c;
if(c>=280)
{clrscr();
i=c-280;
cout<<"Your Change is:P"<<i;}
else
{clrscr();
cout<<"The amount you entered is insufficient";}
}
else
{clrscr();
cout<<"ERROR!";
goto stop;
}
cout<<"\n\nwould you like to place a new order? Y(Yes) N(No)";
cin>>m;
if(m=='y')
{cout<<"\n\n";}
else if (m=='n')
{cout<<" ";
goto stop;
}
else
{cout<<" ";
goto stop;
}
break;
case 'b':
clrscr();
int i1,z,c2;
char m1;
cout<<"Press the number of the Foods you like:\n\n";
cout<<"1.Bicol Express . . . . . . .P250\n2.Sinigang Na Hipon . . . . . . .P180\n3.Crispy Chicken . . . . . . .P300\n\n";
cin>>z;
if(z==1)
{clrscr();
cout<<"Your Balance is:P250";
cout<<"\n\nEnter the amount of your cash:";
cin>>c2;
if(c2>=250)
{clrscr();
i1=c2-250;
cout<<"Your change is:P"<<i1; }
else
{clrscr();
cout<<"The amount you entered is insufficient";}
}
else if(z==2)
{clrscr();
cout<<"Your Balance is P180";
cout<<"\n\nEnter your amount of your cash:";
cin>>c2;
if(c2>=180)
{clrscr();
i1=c2-180;
cout<<"Your change is P"<<i1; }
else
{clrscr();
cout<<"The amount you entered is insufficient";}
}
else if(z==3)
{clrscr();
cout<<"Your Balance is: P300";
cout<<"\n\nEnter the amount of your cash:";
cin>>c2;
if(c2>=300)
{clrscr();
i1=c2-300;
cout<<"Your change is:P"<<i1; }
else
{clrscr();
cout<<"The amount you entered is insufficient";}
}
else
{clrscr();
cout<<"ERROR!";
goto stop;
}
cout<<"\n\nwould you to place another order? Y(Yes) N(No)";
cin>>m1;
if(m1=='y')
{clrscr();
cout<<"\n\n";}
else if(m1=='n')
{clrscr();
cout<<" ";
goto stop;}
else
{clrscr();
cout<<" ";
goto stop;}
break;
case 'c':
int i2,q,c1;
char m2;
cout<<"Press the number of the Drinks you like:\n\n";
cout<<"1.Coke . . . . . . . P10\n2.Sprite . . . . . . . P12\n3.Ice Tea . . . . . . . P11\n\n";
cin>>q;
if(q==1)
{clrscr();
cout<<"Your Balance is: P10";
cout<<"\n\nEnter the amount of your cash:";
cin>>c1;
if(c1>=10){
cout<<"Your change is:P"<<i2;}
else
{clrscr();
cout<<"The amount you entared is insufficient";}
}
else if(q==2)
{ clrscr();
cout<<"Your Balance is: P12";
cout<<"\n\nEnter the amount of your cash:";
cin>>c1;
if(c1>=12)
{clrscr();
i2=c1-12;
cout<<"Your Change is:P"<<i2;}
else
{clrscr();
cout<<"The amount you entered is insufficient";}
}
else if(q==3)
{ clrscr();
cout<<"Your Balance is: P11";
cout<<"\n\nEnter the amount of your cash:";
cin>>c1;
if(c1>=11)
{clrscr();
i2=c1-11;
cout<<"Your change is:P"<<i2; }
else
{clrscr();
cout<<"ERROR!";
goto stop;
}
}
cout<<"\n\nwould you luke to continue? Y(Yes) N(No)";
cin>>m2;
if(m2=='y')
{cout<<" ";}
else if (m2=='n')
{cout<<" ";
goto stop;}
else
{cout<<" ";
goto stop;}
break;
case'd':
clrscr();
cout<<"\t\tThank You For Coming ! Come Again !";
break;
default:
clrscr();
cout<<"ERROR!";
break;
}
}while(y=='a' || y=='b' ||y=='c');
getch();
stop:
}