-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPizzaWahala.java
More file actions
254 lines (157 loc) · 5.5 KB
/
PizzaWahala.java
File metadata and controls
254 lines (157 loc) · 5.5 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
import java.util.Scanner;
public class PizzaWahala{
public static void main(String [] args){
printPizzaType();
}
public static void printPizzaType(){
String prompt = """
_______________________________________________________________________
| PIZZA TYPE | NUMBER OF SLICES | PRICE PER BOX|
________________________________________________________________________
| SAPA SIZE | 4 | 2500 |
________________________________________________________________________
| SMALL MONEY | 6 | 2900 |
| | | |
_________________________________________________________________________
| BIG BOYS | 8 | 4000 |
|_______________________|________________________________________________
| ODOGWU | 12 | 5200 |
|________________________________________________________________________
PIZZA TYPE MENU
1 -> Sapa size (4 slices) for 2500
2 -> Small money (6 slices) for 2900
3 -> Big boys (8 slices) for 4000
4 -> Odogwu (12 slices) for 5200
5 -> Exit
""";
System.out.print(prompt);
System.out.print("Enter pizza type: ");
Scanner input = new Scanner(System.in);
String pizzaType = input.nextLine();
switch(pizzaType){
case "1" : printSapaSize();break;
case "2" : printSmallMoney(); break;
case "3" : printBigBoy();break;
case "4" : printOdogwu();
case "5" : System.out.print("Existing");break;
default : System.out.print("you entered wrong");printPizzaType();
}
}
public static void printSapaSize(){
String prompt = """
SAPA SIZES
NUMBER OF SLICES -> 4
PRICES PER BOX -> 2500
""";
System.out.print(prompt);
Scanner input = new Scanner(System.in);
System.out.print("How many guest are you coming for your party? ");
int guest = input.nextInt();
if(guest < 4){
System.out.print("you entered wrong, it is less than the requirement!");
printSapaSize();
}
int box1 = guest / 4;
if(box1 % guest != 0){
box1 = box1 + 1;
}
int leftOver = (box1 * 4)- guest ;
double price = 2500 * box1;
System.out.printf("The number of boxes of pizza to buy is %d %n",box1);
System.out.printf("The number of leftover slices after serving is %d %n", leftOver);
System.out.printf("The amount of boxes of pizza to buy is %.2f %n", price);
System.out.print("Press 0 to go back to Pizza menu: ");
String sapaSize = input.next();
switch(sapaSize){
case "0" -> printPizzaType();
default -> {System.out.print("You entered wrong"); printSapaSize();}
}
}
public static void printSmallMoney(){
String prompt = """
NUMBER OF SLICES -> 6
PRICES PER BOX -> 2900
""";
System.out.print(prompt);
Scanner input = new Scanner(System.in);
System.out.print("How many guest are you inviting? ");
int guest = input.nextInt();
if(guest < 6){
System.out.print("you entered wrong, it is less than the requirement!");
printSmallMoney();
}
int box1 = guest / 6;
if(box1 % guest != 0){
box1 = box1 + 1;
}
int leftOver = (box1 * 6)- guest ;
double price = 2900 * box1;
System.out.printf("The number of boxes of pizza to buy is %d %n",box1);
System.out.printf("The number of leftover slices after serving is %d %n", leftOver);
System.out.printf("The price of boxes of pizza to buy is $ %.2f %n", price);
System.out.print("Press 0 to go back to Pizza menu: ");
String smallMoney = input.next();
switch(smallMoney){
case "0" -> printPizzaType();
default -> {System.out.print("You entered wrong"); printSapaSize();}
}
}
public static void printBigBoy(){
String prompt = """
NUMBER OF SLICES -> 8
PRICES PER BOX -> 4000
""";
System.out.print(prompt);
Scanner input = new Scanner(System.in);
System.out.print("How many guest are you inviting? ");
int guest = input.nextInt();
if(guest < 8){
System.out.print("you entered wrong, it is less than the requirement!");
printBigBoy();
}
int box1 = guest / 8;
if(box1 % guest != 0){
box1 = box1 + 1;
}
int leftOver = (box1 * 8) - guest ;
double price = 4000 * box1;
System.out.printf("The number of boxes of pizza to buy is %d %n",box1);
System.out.printf("The number of leftover slices after serving is %d %n", leftOver);
System.out.printf("The price of boxes of pizza to buy is $ %.2f %n", price);
System.out.print("Press 0 to go back to Pizza menu: ");
String bigBoys = input.nextLine();
switch(bigBoys){
case "0" -> printPizzaType();
default -> {System.out.print("You entered wrong"); printSapaSize();}
}
}
public static void printOdogwu(){
String prompt = """
NUMBER OF SLICES -> 12
PRICES PER BOX -> 5200
""";
System.out.print(prompt);
Scanner input = new Scanner(System.in);
System.out.print("How many guest are you inviting? ");
int guest = input.nextInt();
if(guest < 12){
System.out.print("you entered wrong, it is less than the requirement!");
printOdogwu();
}
int box1 = guest / 12;
if(box1 % guest != 0){
box1 = box1 + 1;
}
int leftOver = (box1 * 12)- guest ;
double price = 5200 * box1;
System.out.printf("The number of boxes of pizza to buy is %d %n",box1);
System.out.printf("The number of leftover slices after serving is %d %n", leftOver);
System.out.printf("The price of boxes of pizza to buy is $ %.2f %n", price);
System.out.print("Press 0 to go back to Pizza menu: ");
String odogwu = input.next();
switch(odogwu){
case "0" -> printPizzaType();
default ->{ System.out.print("You entered wrong"); printOdogwu();}
}
}
}