Skip to content
Advertisement

Can’t implement string output

JavaScript

It is not possible to display the string correctly by condition

If the coffee machine has enough supplies to make the specified amount of coffee, the program should print “Yes, I can make that amount of coffee”. If the coffee machine can make more than that, the program should output “Yes, I can make that amount of coffee (and even N more than that)”, where N is the number of additional cups of coffee that the coffee machine can make. If the amount of resources is not enough to make the specified amount of coffee, the program should output “No, I can make only N cup(s) of coffee”.

Like in the previous stage, the coffee machine needs 200 ml of water, 50 ml of milk, and 15 g of coffee beans to make one cup of coffee.

When outputting by condition, everything is correct, except for the line

JavaScript

If I enter 600 153 100 1, then it will be Yes, I can make that amount of coffee (and even 1 more than that) but this right Yes, I can make that amount of coffee (and even 2 more than that)

Advertisement

Answer

You are making coffees while you have more than enough ingredients.
That means you won’t make a coffee when you have exactly the right amount of ingredients.

Try changing this:

JavaScript

To this:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement