Hello friends, i have got a project work on a question.
Write a program to create a restaurant menu and enter the choice of the user on the basic of choice made calculate the bill to be paid.
I have made this program but i heard it can be done with the help of arryas(i dont know about them as i have not studied) can u give me any hint on my program for making it beautiful and doing it with loops i have used only if condition i think it will be very long as i will add few more items in menu.
I have studied these things- if codition,nested if,while loop,do while loop,for loop,empty,nfinite loop,nested loops,brake statement,continue statemant,exit function.
#include <iostream.h>
#include <conio.h>
void main ()
{ clrscr ();
cout<<" WELCOME TO XYZ RESTAURANT"<<endl;
cout<<"Press any key to show menu"<<endl;
getch ();
int a,b,c,d,abc,xyz,hmm,how_many,price_abc,price_xyz,price_hmm;
abc=1;
xyz=2;
hmm=3;
price_abc=10;
price_xyz=20;
price_hmm=30;
cout<<"MENU"<<endl<<"1.abc.....10"<<endl<<"2.xyz.....20"<<endl<<"3.hmm.....30"<<endl;
cout<<"How many dishes you want to select??"<<endl;
cin>>how_many;
if (how_many==1)
{cout<<"Enter the dish no.";
cin>>a;
if(a==1)
{cout<<"You hae chosen dish abc"<<endl<<"Bill=Rs"<<price_abc<<endl;
}
if(a==2)
{cout<<"You have chosen dish xyz"<<endl<<"Bill=Rs"<<price_xyz<<endl;
}
if(a==3)
{cout<<"You have chosen dish hmm"<<endl<<"Bill=Rs"<<price_hmm<<endl;
}
getch();
}
if (how_many==2)
{
cout<<"To select a dish enter its no. one by one"<<endl;
cin>>a;
cin>>b;
if (a==1)
{cout<<"You have selected abc of Rs 10"<<endl;
}
if (a==2)
{cout<<"You have selected xyz of Rs 20"<<endl;
}
if (a==3)
{cout<<"You have selected hmm of Rs 30"<<endl;
}
if (b==1)
{cout<<"You have selected abc of Rs 10"<<endl;
}
if (b==2)
{cout<<"You have selected xyz of Rs 20"<<endl;
}
if (b==3)
{cout<<"You have selected hmm of Rs 30"<<endl;
}
if (a==1 && b==1)
{ cout<<"Bill="<<price_abc+price_abc<<endl;
}
if (a==1 && b==2)
{ cout<<"Bill="<<price_abc+price_xyz<<endl;
}
if (a==1 && b==3)
{ cout<<"Bill="<<price_abc+price_hmm<<endl;
}
if (a==2 && b==1)
{cout<<"Bill="<<price_xyz + price_abc<<endl;
}
if (a==2 && b==2)
{ cout<<"Bill="<<price_xyz+price_xyz<<endl;
}
if (a==2 && b==3)
{ cout<<"Bill="<<price_xyz+price_hmm<<endl;
}
if (a==3 && b==1)
{ cout<<"Bill="<<price_hmm+price_abc<<endl;
}
if (a==3 && b==2)
{ cout<<"Bill="<<price_hmm+price_xyz<<endl;
}
if (a==3 && b==3)
{ cout<<"Bill="<<price_hmm+price_hmm<<endl;
}
}
if (how_many==3)
{
cout<<"To select a dish enter its no. one by one"<<endl;
cin>>a;
cin>>b;
cin>>c;
if (a==1)
{cout<<"You have selected abc of Rs10"<<endl;
}
if (a==2)
{cout<<"You have selected xyz of Rs20"<<endl;
}
if (a==3)
{cout<<"You have selected hmm of Rs30"<<endl;
}
if (b==1)
{cout<<"You have selected abc of Rs 10"<<endl;
}
if (b==2)
{cout<<"You have selected xyz of Rs 20"<<endl;
}
if (b==3)
{cout<<"You have selected hmm of Rs 30"<<endl;
}
if (c==1)
{cout<<"You have selected abc of Rs10"<<endl;
}
if (c==2)
{cout<<"You have selected xyz of Rs20"<<endl;
}
if (c==3)
{cout<<"You have selected hmm of Rs30"<<endl;
}
if (a==1 && b==1 && c==1)
{cout<<"Bill="<<price_abc+price_abc+price_abc<<endl;
}
if (a==1 && b==1 && c==2)
{cout<<"Bill="<<price_abc+price_abc+price_xyz<<endl;
}
if (a==1 && b==1 && c==3)
{cout<<"Bill="<<price_abc+price_abc+price_hmm<<endl;
}
if (a==1 && b==2 && c==1)
{cout<<"Bill="<<price_abc+price_xyz+price_abc<<endl;
}
}
getch ();
}