SHARE
TWEET

Untitled

a guest Aug 24th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.danielw231.coffee;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class CoffeeMachine
  6. {
  7.     public static void main(String[] args)
  8.     {
  9.         int water;
  10.         int milk;
  11.         int coffeeBeans;
  12.         int amount;
  13.  
  14.         int cupsAvailable = 0;
  15.  
  16.         Scanner scanner = new Scanner(System.in);
  17.  
  18.         System.out.println("How much water do you have? ");
  19.         water = scanner.nextInt();
  20.         System.out.println("How much milk do you have? ");
  21.         milk = scanner.nextInt();
  22.         System.out.println("How many coffee beans do you have? ");
  23.         coffeeBeans = scanner.nextInt();
  24.         System.out.println("Hello! How many coffees would you like to make? ");
  25.         amount = scanner.nextInt();
  26.  
  27.         if (water > 200 && milk > 50 && coffeeBeans > 15)
  28.         {
  29.             if (water <  200)
  30.             {
  31.                 System.out.println("Not enough water!");
  32.             }
  33.  
  34.             else if (milk < 50)
  35.             {
  36.                 System.out.println("Not enough milk!");
  37.             }
  38.  
  39.             else if (coffeeBeans < 15)
  40.             {
  41.                 System.out.println("Not enough coffee beans!");
  42.             }
  43.  
  44.             else
  45.                 {
  46.                     int availableWater = water / 200;
  47.                     int availableMilk = milk / 50;
  48.                     int availableCoffee = coffeeBeans / 50;
  49.  
  50.                     cupsAvailable = Math.min(Math.min(availableWater, availableMilk), availableCoffee);
  51.                 }
  52.         }
  53.  
  54.         if (amount > cupsAvailable)
  55.         {
  56.             System.out.println("No, I can only make " + cupsAvailable + " cup(s) of coffee...");
  57.         }
  58.  
  59.         else if (amount < cupsAvailable)
  60.         {
  61.             System.out.println("Yes, I can make that amount of coffee (and even " + (cupsAvailable - amount) + " cup(s) of coffee)!");
  62.         }
  63.  
  64.         else {
  65.             System.out.println("Yes, I can make that amount of coffee!");
  66.         }
  67.     }
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top