-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME4.html
More file actions
115 lines (85 loc) · 3.66 KB
/
README4.html
File metadata and controls
115 lines (85 loc) · 3.66 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
<h2>Description</h2>
<p>But just one action isn’t interesting. Let's improve the program so it can do multiple actions, one after another. The program should repeatedly ask what the user wants to do. If the user types "buy", "fill" or "take", then just do what the program did in the previous step. However, if the user wants to switch off the coffee machine, he should type "exit". Then the program should terminate. Also, when the user types "remaining", the program should output all the resources that the coffee machine has.</p>
<p>Also, do not forget that you can be out of resources for making coffee. If the coffee machine doesn’t have enough resources to make coffee, the program should output a message that says it can't make a cup of coffee.</p>
<p>And the last improvement to the program at this step—if the user types "buy" to buy a cup of coffee and then changes his mind, he should be able to type "back" to return into the main cycle.</p>
<p>Remember, that:</p>
<ul>
<li>For the espresso, the coffee machine needs 250 ml of water and 16 g of coffee beans. It costs $4.</li>
<li>For the latte, the coffee machine needs 350 ml of water, 75 ml of milk, and 20 g of coffee beans. It costs $7.</li>
<li>And for the cappuccino, the coffee machine needs 200 ml of water, 100 ml of milk, and 12 g of coffee. It costs $6.</li>
</ul>
<h2>Instruction</h2>
<p>Write a program that will work endlessly to make coffee for all interested persons until the shutdown signal is given.</p>
<h2>Example</h2>
<p>Your coffee machine should have the same initial resources as in the example (400 ml of water, 540 ml of milk, 120 g of coffee beans, 9 disposable cups, $550 in cash).<br>
The symbol <code class="java">></code> represents the user input. Notice that it's not the part of the input.</p>
<pre><code class="language-no-highlight">Write action (buy, fill, take, remaining, exit):
> remaining
The coffee machine has:
400 of water
540 of milk
120 of coffee beans
9 of disposable cups
$550 of money
Write action (buy, fill, take, remaining, exit):
> buy
What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:
> 2
I have enough resources, making you a coffee!
Write action (buy, fill, take, remaining, exit):
> remaining
The coffee machine has:
50 of water
465 of milk
100 of coffee beans
8 of disposable cups
$557 of money
Write action (buy, fill, take, remaining, exit):
> buy
What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:
> 2
Sorry, not enough water!
Write action (buy, fill, take, remaining, exit):
> fill
Write how many ml of water do you want to add:
> 1000
Write how many ml of milk do you want to add:
> 0
Write how many grams of coffee beans do you want to add:
> 0
Write how many disposable cups of coffee do you want to add:
> 0
Write action (buy, fill, take, remaining, exit):
> remaining
The coffee machine has:
1050 of water
465 of milk
100 of coffee beans
8 of disposable cups
$557 of money
Write action (buy, fill, take, remaining, exit):
> buy
What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:
> 2
I have enough resources, making you a coffee!
Write action (buy, fill, take, remaining, exit):
> remaining
The coffee machine has:
700 of water
390 of milk
80 of coffee beans
7 of disposable cups
$564 of money
Write action (buy, fill, take, remaining, exit):
> take
I gave you $564
Write action (buy, fill, take, remaining, exit):
> remaining
The coffee machine has:
700 of water
390 of milk
80 of coffee beans
7 of disposable cups
0 of money
Write action (buy, fill, take, remaining, exit):
> exit</code></pre>