Program on Show menu and calculate bill

closed account (G2zC5Di1)
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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  #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 ();
}


I dont know abot that but u can do the same using a stucture of arrays
Topic archived. No new replies allowed.