H3LP!!! Ordering machine Program C++

anyone please help me!!! i have made this program


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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{dale:
char or;
int a1,b1,f1,g1=0,w1,c1=0,d1=0,h1,total1,u1,z1;

{
cout<<"\t\t\t\t\MENU FOR THE DAY";
cout<<"\n";
cout<<"\n";
cout<<"SNACKS";
cout<<"\n1. Arrozcaldo-----------------------P10.00";
cout<<"\n2. Arrozcaldo with egg--------------P13.00";
cout<<"\n3. Arrozcaldo with chicken----------P15.00";
cout<<"\n4. Pancit Bihon---------------------P10.00";
cout<<"\n5. Macaroni Salad-------------------P15.00";
cout<<"\n6. Buko Salad-----------------------P15.00";
cout<<"\n7. Spaghetti------------------------P15.00";
cout<<"\n8. No Order";
cout<<"\n\n\t\tEnter the number of your order:";
cin>>a1;
switch(a1)
{
case 1:
c1=10;
cout<<"\t\tYou ordered Arozcaldo";
break;
case 2:
c1=13;
cout<<"\t\tYou ordered Arozcaldo with egg";
break;
case 3:
c1=15;
cout<<"\t\tYou ordered Arozcaldo with chicken";
break;
case 4:
c1=10;
cout<<"\t\tYou ordered Pancit Bihon";
break;
case 5:
c1=15;
cout<<"\t\tYou ordered Macaroni Salad";
break;
case 6:
c1=15;
cout<<"\t\tYou ordered Buko Salad";
break;
case 7:
c1=15;
cout<<"\t\tYou ordered Spaghetti";
break;
case 8:
c1=0;
cout<<"\t\tNo Order";
}
cout<<"\n\t\tHow many orders:";
cin>>b1;z1=c1*b1;
clrscr();
{
{
jay:
cout<<"\n\n\n";
cout<<"MEALS";
cout<<"\n1.Bulalo,Rice,Drinks,Vegetables------------P50.00";
cout<<"\n2.Adobong Manok,Rice,Drinks,Vegetables-----P35.00";
cout<<"\n3.Tinolang Manok,Rice,Drinks,Vegetables----P35.00";
cout<<"\n4.Paksiw,Rice,Drinks,Vegetables------------P60.00";
cout<<"\n5.Kare-Kare,Rice,Drinks,Vegetables---------P40.00";
cout<<"\n6.Dinuguan,Rice,Drinks,Vegetables----------P25.00";
cout<<"\n7.Igado,Rice,Drinks,Vegetables-------------P30.00";
cout<<"\n8.Pritong Isda,Rice,Drinks,Vegetables------P25.00";
cout<<"\n9.Beef steak,Rice,Drinks,Vegetables--------P35.00";
cout<<"\n10.Chicken Carrey,Rice,Drinks,Vegetables---P35.00";
cout<<"\n\n\t\tEnter the number of your order:";
cin>>h1;
switch(h1)
{
case 1:
d1=50;
cout<<"\t\tYou ordered Bulalo,Rice,Drinks,Vegetables";
break;
case 2:
d1=35;
cout<<"\t\tYou ordered Adobong Manok,Rice,Drinks,Vegetables";
break;
case 3:
d1=35;
cout<<"\t\tYou ordered Tinolang Manok,Rice,Drinks,Vegetables";
break;
case 4:
d1=60;
cout<<"\t\tYou ordered Paksiw,Rice,Drinks,Vegetables";
break;
case 5:
d1=40;
cout<<"\t\tYou ordered Kare-Kare,Rice,Drinks,Vegetables";
break;
case 6:
d1=25;
cout<<"\t\tYou ordered Dinuguan,Rice,Drinks,Vegetables";
break;
case 7:
d1=30;
cout<<"\t\tYou ordered Igado,Rice,Drinks,Vegetables";
break;
case 8:
d1=25;
cout<<"\t\tYou ordered Pritong Isda,Rice,Drinks,Vegetables";
break;
case 9:
d1=35;
cout<<"\t\tYou ordered Beef steak,Rice,Drinks,Vegetables";
break;
case 10:
d1=35;
cout<<"\t\tYou ordered Chicken Carrey,Rice,Drinks,Vegetables";
break;
}
cout<<"\n\t\tHow many orders:";
cin>>w1;
u1=w1*d1;}
}
clrscr();
cout<<"Do yo want additional order?[y/n]";
cin>>or;
switch(or)
{
case 'y':
goto dale;
case 'n':
break;}
clrscr();
{
total1=z1+u1;
cout<<"\n\n\nThe amount you will be paying is"<<" "<<"P"<<total1;
cout<<"\n\n\n\n";
do {
cout<<"\n\nEnter Cash Amount:";
cin>>f1;

clrscr();
if(f1<total1)
{
cout<<"Insufficient amount!";
}
}
while(f1<total1);
g1=f1-total1;
cout<<"\n\n";
cout<<"\n\n\t\t\t\tYour change is"<<" "<<g1;
cout<<"\n\n";
cout<<"\t\tThank you for ordering at BEN's Restaurant";
cout<<"\n\n\t\t\t\tCome again!";
}
}
}


the problem is when i order again it no longer add the amount of what was previously ordered..

also when I type in wrong no. or character it should say invalid choice and try again..

can some one help me out, i do not know what to with those problems pls help..

this is my project and the deadline for submission is this coming friday pls help...

codes would be appreciated very much
Last edited on
Hey,
You need a variable keeping up with the previously amout and then add it to the total1 variable. Also, you need to add a default case to your switch cases so when a wrong no. or character i enterened it would say invalid choice and try again.

For Example:
case 1:
c1=10;
cout<<"\t\tYou ordered Arozcaldo";
break;
case 2:
c1=13;
cout<<"\t\tYou ordered Arozcaldo with egg";
break;
case 3:
c1=15;
cout<<"\t\tYou ordered Arozcaldo with chicken";
break;
case 4:
c1=10;
cout<<"\t\tYou ordered Pancit Bihon";
break;
case 5:
c1=15;
cout<<"\t\tYou ordered Macaroni Salad";
break;
case 6:
c1=15;
cout<<"\t\tYou ordered Buko Salad";
break;
case 7:
c1=15;
cout<<"\t\tYou ordered Spaghetti";
break;
case 8:
c1=0;
default:
(Message goes here)



Also, you may want to put break; in between your cases, thats good practice. Hope this helps!!! Keep me posted!


Hey,
You need a variable keeping up with the previously amount and then add it to the total1 variable. Also, you need to add a default case to your switch cases so when a wrong no. or character i entered it would say invalid choice and try again.


Yes i know that, but when ever i try to add a default case and then run the program... if i try to enter a wrong no. or character the output becomes



Insufficient Fund!

Enter Cash Amount:


and it keeps flashing and the program stop responding..

Pls help what should i do?
Did adding a variable to keep up with the previously amout work?
As for the default case are you putting it in the right place (should be directly a/f case:10 followed by no break;). By the way what are you using to compile the program with and what system(Linux,Windows,Unix?) are to running it on. I ask b/c I am not familiar with such code as goto dale;
Ok just read up on goto statements, I think it will be easier for you to use function call rather that goto statements if you are allowed to use them. They will make it easier to understand your code.
Yeah, functions > gotos in this case...I would just make functions:

OrderMeal()
OrderSnack()
etc...

And then make a while loop to check whether they want to keep ordering.
Topic archived. No new replies allowed.