-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStage4.java
More file actions
201 lines (178 loc) · 7.15 KB
/
Stage4.java
File metadata and controls
201 lines (178 loc) · 7.15 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
import java.util.Scanner;
public class CoffeeMachine {
public static void displayIngredients(int water, int milk, int coffee, int numDispCups, int moneyInMac){
System.out.println();
System.out.println("The coffee machine has:");
System.out.println(water + " of water");
System.out.println(milk + " of milk");
System.out.println(coffee + " of coffee beans");
System.out.println(numDispCups + " of disposable cups");
if (moneyInMac == 0) {
System.out.println(moneyInMac + " of money");
} else {
System.out.println("$" + moneyInMac + " of money");
}
System.out.println();
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int water = 400;
int milk = 540;
int coffee = 120;
int numDispCups = 9;
int moneyInMac = 550;
System.out.println("Write action (buy, fill, take):");
String command = scanner.next();
while (!command.equals("exit")) {
if (command.equals("buy")) {
System.out.println();
System.out.println("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino:, back - to main menu:");
String coffeeType = scanner.next();
switch (coffeeType) {
case "1":
if (water < 250){
System.out.println("Sorry, not enough water!");
break;
} else if (coffee < 16) {
System.out.println("Sorry, not enough coffee!");
break;
} else if (numDispCups == 0) {
System.out.println("Sorry, not enough cups!");
break;
}
System.out.println("I have enough resources, making you a coffee!");
System.out.println();
water -= 250;
coffee -= 16;
moneyInMac += 4;
numDispCups--;
break;
case "2":
if (water < 350){
System.out.println("Sorry, not enough water!");
break;
} else if (milk < 75) {
System.out.println("Sorry, not enough milk!");
break;
} else if (coffee < 20) {
System.out.println("Sorry, not enough coffee!");
break;
} else if (numDispCups == 0) {
System.out.println("Sorry, not enough cups!");
break;
}
System.out.println("I have enough resources, making you a coffee!");
water -= 350;
milk -= 75;
coffee -= 20;
moneyInMac += 7;
numDispCups--;
break;
case "3":
if (water < 200){
System.out.println("Sorry, not enough water!");
break;
} else if (milk < 100) {
System.out.println("Sorry, not enough milk!");
break;
} else if (coffee < 12) {
System.out.println("Sorry, not enough coffee!");
break;
} else if (numDispCups == 0) {
System.out.println("Sorry, not enough cups!");
break;
}
water -= 200;
milk -= 100;
coffee -= 12;
moneyInMac += 6;
numDispCups--;
break;
case "back":
;
}
} else if (command.equals("fill")) {
System.out.println();
System.out.println("Write how many ml of water do you want to add:");
int newWater = scanner.nextInt();
System.out.println("Write how many ml of milk do you want to add:");
int newMilk = scanner.nextInt();
System.out.println("Write how many grams of coffee beans do you want to add:");
int newCoffee = scanner.nextInt();
System.out.println("Write how many disposable cups of coffee do you want to add:");
int newCups = scanner.nextInt();
water += newWater;
milk += newMilk;
coffee += newCoffee;
numDispCups += newCups;
} else if (command.equals("take")) {
System.out.println();
System.out.println("I gave you $" + moneyInMac);
moneyInMac = 0;
} else if (command.equals("remaining")) {
displayIngredients(water, milk, coffee, numDispCups, moneyInMac);
}
System.out.println();
System.out.println("Write action (buy, fill, take):");
command = scanner.next();
}
}
}
//switch (command) {
// case "buy":
// System.out.println("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:");
// int coffeeType = scanner.nextInt();
// switch (coffeeType) {
// case 1:
// if (water < 250) {
// System.out.println("Sorry, not enough of water!");
// continue;
// }
// if (coffee < 16) {
//
// }
// water -= 250;
// coffee -= 16;
// moneyInMac += 4;
// break;
// case 2:
// water -= 350;
// milk -= 75;
// coffee -= 20;
// moneyInMac += 7;
// break;
// case 3:
// water -= 200;
// milk -= 100;
// coffee -= 12;
// moneyInMac += 6;
// break;
// }
// numDispCups--;
// break;
//
// case "fill":
// System.out.println("Write how many ml of water do you want to add:");
// int newWater = scanner.nextInt();
// System.out.println("Write how many ml of milk do you want to add:");
// int newMilk = scanner.nextInt();
// System.out.println("Write how many grams of coffee beans do you want to add:");
// int newCoffee = scanner.nextInt();
// System.out.println("Write how many disposable cups of coffee do you want to add:");
// int newCups = scanner.nextInt();
//
// water += newWater;
// milk += newMilk;
// coffee += newCoffee;
// numDispCups += newCups;
// break;
//
// case "take":
// System.out.println("I gave you $" + moneyInMac);
// moneyInMac = 0;
// break;
//
// case "remaining":
// displayIngredients(water, milk, coffee, numDispCups, moneyInMac);
// break;
// }