-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCafe.c
192 lines (176 loc) · 5.1 KB
/
Cafe.c
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include <stdio.h>
// the amount of foods and drinks
#define cake 40
#define cookie 40
#define coffee 40
#define tea 40
// the price of foods and drinks
#define cake_price 3
#define cookie_price 2
#define coffee_price 6
#define tea_price 4
int choice;
int i = 1;
long total; // the variable that keeps the total price of foods and drinks
// the function that shows the cafe menu
int cake_number, cookie_number, coffee_number, tea_number;
void menu(void) {
printf("What do you want to buy?\n");
printf("1: Cake 2: Cookie 3: Coffee 4: tea \n");
}
// function that mesure the number of food and drinks
void order_amount(int m) {
if (m == 1)
cake_number++;
else if (m == 2)
cookie_number++;
else if (m == 3)
coffee_number++;
else if (m == 4)
tea_number++;
}
void take_photo(void) {
int photo;
printf("Do you want to take photo? 1: 'YES' , 0: 'NO'");
scanf("%d", &photo);
if (photo == 1) {
printf("BE READY\n");
printf("TAK\n\n");
}
else if (photo == 0)
printf("NO PROBLEM, what ever you Sir/Madam");
else
printf("Invalid input!!!");
int k = 0;
while (k <= 100000000)
{
k++;
}
if (photo == 1) {
printf("Here is your photo!!!\n\n");
printf("..........000...000..........\n");
printf(".........00000.00000.........\n");
printf("........0000000000000........\n");
printf("........0000000000000........\n");
printf(".........00000000000.........\n");
printf("..........000000000..........\n");
printf("...........0000000...........\n");
printf("............00000............\n");
printf(".............000.............\n");
printf("..............0..............\n");
}
}
void buy(int m) {
if (m == 1)
total += cake_price;
else if (m == 2)
total += cookie_price;
else if (m == 3)
total += coffee_price;
else if (m ==4)
total += tea_price;
}
int choice_fun(int n) {
if (n <= 0)
return 1;
switch (n) {
case 1:
buy(n);
order_amount(n);
i++;
printf("You ordered cake\n");
printf("___________________________________________\n");
break;
case 2:
buy(n);
order_amount(n);
i++;
printf("You ordered cookie\n");
printf("___________________________________________\n");
break;
case 3:
buy(n);
order_amount(n);
i++;
printf("You ordered coffee\n");
printf("___________________________________________\n");
break;
case 4:
buy(n);
order_amount(n);
i++;
printf("You ordered tea\n");
printf("___________________________________________\n");
break;
default:
printf("invalid input!\n");
printf("Please order again\n\n");
break;
}
}
// function for paying money
void pay(void) {
int way = 0;
long money = 0;
printf("Pay the money please!!!\n");
printf("how do want to pay? 1: phisycal money or 2: Card\n");
scanf("%d", &way);
// funtion that print the amount of orders
if (way == 1) {
printf("Please give the money?");
scanf("%ld", &money);
if (money == total)
printf("THANKS A LOT\n");
else {
printf("please pay the money completly!!!\n");
pay();
}
}
// funtion that print the amount of orders
else if (way == 2) {
int card_code;
printf("Please draw your card\n");
printf("Enter your card code?");
scanf("%d", &card_code);
printf("Enter the amount of money and pay?");
scanf("%ld", &money);
if (money == total)
printf("THANKS A LOT\n");
else {
printf("please pay the money completly!!!\n");
pay();
}
}
else // if the costomer do not pay completly
pay();
}
// funtion that print the amount of orders
void print_orders(void) {
if (cake_number != 0)
printf("You ordered <%d> %s, it cost %d$\n", cake_number, "cake", cake_number * cake_price);
if (cookie_number != 0)
printf("You ordered <%d> %s, it cost %d$\n", cookie_number, "cookie", cookie_number * cookie_price);
if (coffee_number != 0)
printf("You ordered <%d> %s, it cost %d$\n", coffee_number, "coffee",coffee_number * coffee_price);
if (tea_number != 0)
printf("You ordered <%d> %s, it cost %d$\n", tea_number, "tea", tea_number * tea_price);
}
int main() {
printf("welcome to HACKER`S CAFE!\n");
int n;
printf("ENTER THE NUMBER OF YOUR REQUSTS?");
scanf("%d", &n);
printf("___________________________________________\n");
while(i <= n) {
printf("The %d order\n");
menu();
scanf("%d", &choice);
choice_fun(choice);
}
printf("You ordered %d things\n", n);
// funtion that print the amount of orders
print_orders();
printf("The total cost is %ld$\n\n", total);
pay();
take_photo();
}