Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.danielw231.coffee;
- import java.util.Scanner;
- public class CoffeeMachine
- {
- public static void main(String[] args)
- {
- int water;
- int milk;
- int coffeeBeans;
- int amount;
- int cupsAvailable = 0;
- Scanner scanner = new Scanner(System.in);
- System.out.println("How much water do you have? ");
- water = scanner.nextInt();
- System.out.println("How much milk do you have? ");
- milk = scanner.nextInt();
- System.out.println("How many coffee beans do you have? ");
- coffeeBeans = scanner.nextInt();
- System.out.println("Hello! How many coffees would you like to make? ");
- amount = scanner.nextInt();
- if (water > 200 && milk > 50 && coffeeBeans > 15)
- {
- if (water < 200)
- {
- System.out.println("Not enough water!");
- }
- else if (milk < 50)
- {
- System.out.println("Not enough milk!");
- }
- else if (coffeeBeans < 15)
- {
- System.out.println("Not enough coffee beans!");
- }
- else
- {
- int availableWater = water / 200;
- int availableMilk = milk / 50;
- int availableCoffee = coffeeBeans / 50;
- cupsAvailable = Math.min(Math.min(availableWater, availableMilk), availableCoffee);
- }
- }
- if (amount > cupsAvailable)
- {
- System.out.println("No, I can only make " + cupsAvailable + " cup(s) of coffee...");
- }
- else if (amount < cupsAvailable)
- {
- System.out.println("Yes, I can make that amount of coffee (and even " + (cupsAvailable - amount) + " cup(s) of coffee)!");
- }
- else {
- System.out.println("Yes, I can make that amount of coffee!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement