Advertisement
uriahheep

Untitled

Jun 16th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.32 KB | None | 0 0
  1. package machine;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class CoffeeMachine {
  6.     public static void main(String[] args) {
  7.  
  8. //        System.out.println("Starting to make a coffee");
  9. //        System.out.println("Grinding coffee beans");
  10. //        System.out.println("Boiling water");
  11. //        System.out.println("Mixing boiled water with crushed coffee beans");
  12. //        System.out.println("Pouring coffee into the cup");
  13. //        System.out.println("Pouring some milk into the cup");
  14. //        System.out.println("Coffee is ready!");
  15.         Scanner input = new Scanner(System.in);
  16. //        System.out.println("Input the amount of cups you need: ");
  17. //        int amount = input.nextInt();
  18. //        int water = 200 * amount;
  19. //        int milk = 50 * amount;
  20. //        int beans = 15 * amount;
  21. //        System.out.println("For " + amount + " cups of coffee, you will need:");
  22. //        System.out.println(water + " ml of water");
  23. //        System.out.println(milk + " ml of milk");
  24. //        System.out.println(beans + " g of beans");
  25. //        System.out.println("Specify the amount of water in the coffee machine in ml's:");
  26. //        int waterAmount = input.nextInt();
  27. //        System.out.println("Specify the amount of milk in the coffee machine in ml's:");
  28. //        int milkAmount = input.nextInt();
  29. //        System.out.println("Specify the amount of coffee beans in the coffee machine in grams:");
  30. //        int beansAmount = input.nextInt();
  31. //        System.out.println("How many cups of coffee will you need?");
  32. //        int cupsAmount = input.nextInt();
  33. //
  34. //        int cupsPossible = 0;
  35. //        while (waterAmount >= 200 && milkAmount >= 50 && beansAmount >= 15) {
  36. //            cupsPossible++;
  37. //            waterAmount = waterAmount - 200;
  38. //            milkAmount = milkAmount - 50;
  39. //            beansAmount = beansAmount - 15;
  40. //        }
  41. //        int additionalCups = cupsPossible - cupsAmount;
  42. //
  43. //
  44. //        if (cupsPossible == cupsAmount) {
  45. //            System.out.println("Yes, I can make that amount of coffee");
  46. //        } else if (cupsPossible > cupsAmount) {
  47. //            System.out.println("Yes, I can make that amount of coffee (and even " + additionalCups + " cup(s) more than that)");
  48. //        } else {
  49. //            System.out.println("No, I can make only " + cupsPossible + " cup(s) of coffee");
  50. //        }
  51.         int waterAmount = 400;
  52.         int milkAmount = 540;
  53.         int beansAmount = 120;
  54.         int cupsAmount = 9;
  55.         int money = 550;
  56.         systemCheck(waterAmount, milkAmount, beansAmount, cupsAmount, money);
  57.         System.out.println("Write action (buy, fill, take): ");
  58.         String action = input.next();
  59.         switch (action){
  60.             case "buy":
  61.                 buyDrink(waterAmount, milkAmount, beansAmount, cupsAmount, money);
  62.                 break;
  63.             case "fill":
  64.                 fillMachine();
  65.                 break;
  66.             case "take":
  67.                 getCash();
  68.                 break;
  69.             default:
  70.                 System.out.println("Wrong choice!");
  71.         }
  72.        
  73.         systemCheck(waterAmount, milkAmount, beansAmount, cupsAmount, money);
  74.  
  75.  
  76.  
  77.  
  78.  
  79.     }
  80.     public static void systemCheck(int water, int milk, int beans, int cups, int money){
  81.         System.out.println("The coffee machine has: ");
  82.         System.out.println(water + " of water");
  83.         System.out.println(milk + " of milk");
  84.         System.out.println(beans + " of coffee beans");
  85.         System.out.println(cups + " of disposable cups");
  86.         System.out.println(money + " of money");
  87.     }
  88.  
  89.  
  90.  
  91.     public static int[] buyDrink(int water, int milk, int beans, int cups, int money){
  92.         Scanner in = new Scanner(System.in);
  93.         System.out.println("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino: ");
  94.         int choice = in.nextInt();
  95.         switch (choice) {
  96.             case 1:
  97.                 if (water >= 250 && beans >= 16 && cups > 0){
  98.                     water = water - 250;
  99.                     beans = beans - 16;
  100.                     money = money + 4;
  101.                     cups = cups - 1;
  102.                 }else
  103.                     System.out.println("Not enough ingredients, fill the machine please");
  104.                 break;
  105.             case 2:
  106.                 if (water >= 350 && milk >= 75 && beans >= 20 && cups > 0){
  107.                     water = water - 350;
  108.                     milk = milk - 75;
  109.                     beans = beans - 20;
  110.                     money = money + 7;
  111.                     cups = cups - 1;
  112.                 } else
  113.                     System.out.println("Not enough ingredients, fill the machine please");
  114.                 break;
  115.             case 3:
  116.                 if (water >= 200 && milk >= 100 && beans >= 12 && cups > 0){
  117.                     water = water - 200;
  118.                     milk = milk - 100;
  119.                     beans = beans - 12;
  120.                     cups = cups - 1;
  121.                 } else
  122.                     System.out.println("Not enough ingredients, fill the machine please");
  123.                 break;
  124.             default:
  125.                 System.out.println("Wrong choice!");
  126.  
  127.         }
  128.         return new int[] {water, milk, beans, money, cups};
  129.     }
  130.     public static void fillMachine(){
  131.  
  132.     }
  133.     public static void getCash(){
  134.  
  135.     }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement