-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPizzaWahala2.java
More file actions
74 lines (53 loc) · 2.01 KB
/
Copy pathPizzaWahala2.java
File metadata and controls
74 lines (53 loc) · 2.01 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
import java.util.Scanner;
public class PizzaWahala2 {
public static String ViewingPizzaTypes(String menu) {
menu = """
Pizza type Number of Slices Price per Box
Sapa Size 4 2000
Small Money 6 2400
Big Boys 8 3000
Odogwu 12 4200
""";
return menu;
}
public static void main(String... args) {
Scanner input = new Scanner(System.in);
String menu = "";
System.out.println(ViewingPizzaTypes(menu));
System.out.println("What type of Pizza do you want to buy?");
String receiveOrder = input.nextLine().toLowerCase();
int pizzaSlice = 0;
int prize = 0;
switch (receiveOrder) {
case "sapa size" -> {
pizzaSlice = 4;
prize = 2000;
}
case "small money" -> {
pizzaSlice = 6;
prize = 2400;
}
case "big boys" -> {
pizzaSlice = 8;
prize = 3000;
}
case "odogwu" -> {
pizzaSlice = 12;
prize = 4200;
}
default -> {
System.out.println("Invalid input!!");
return;
}
}
System.out.println("How many people?");
int numberOfPeople = input.nextInt();
double numberOfBoxes = Math.ceil((double) numberOfPeople / pizzaSlice);
double pizzaPrice = prize * numberOfBoxes;
int totalSlices = (int) (numberOfBoxes * pizzaSlice);
int leftOverPizza = totalSlices - numberOfPeople;
System.out.printf(
"%s pizza contains %d slices per box.\n%.0f box(es) will serve %d people.\nTotal slices: %d\nLeftover slices: %d\nTotal cost: ₦%.2f\n",
receiveOrder, pizzaSlice, numberOfBoxes, numberOfPeople, totalSlices, leftOverPizza, pizzaPrice);
}
}