A local juice bar uses a program to determine if they have enough orange juice in stock for a large catering event, or how many more litres they need to order.
Each Large cocktail requires 0.2 litres of orange juice. Each Regular cocktail requires 0.1 litres of orange juice.
Here is the buggy program:
stock = float(input('Juice in stock (litres): '))
large = int(input('Number of large: '))
regular = int(input('Number of regular: '))
needed = (large * 2.0) + (regular * 0.1)
if stock < needed:
print('Juice in stock sufficient')
else:
shortfall = stock - needed
print('Order ' + shortfall + ' litres')
There are four errors in the code.
Amend the code to correct the four errors.
Use this test data to help you find the errors:
| Juice in stock (litres) | Number of large | Number of regular | Expected output |
|---|---|---|---|
| 28 | 80 | 120 | Juice in stock sufficient |
| 22 | 80 | 120 | Order 6.0 litres |