Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package machine;
- import java.util.Scanner;
- public class CoffeeMachine {
- public static void main(String[] args) {
- // System.out.println("Starting to make a coffee");
- // System.out.println("Grinding coffee beans");
- // System.out.println("Boiling water");
- // System.out.println("Mixing boiled water with crushed coffee beans");
- // System.out.println("Pouring coffee into the cup");
- // System.out.println("Pouring some milk into the cup");
- // System.out.println("Coffee is ready!");
- Scanner input = new Scanner(System.in);
- // System.out.println("Input the amount of cups you need: ");
- // int amount = input.nextInt();
- // int water = 200 * amount;
- // int milk = 50 * amount;
- // int beans = 15 * amount;
- // System.out.println("For " + amount + " cups of coffee, you will need:");
- // System.out.println(water + " ml of water");
- // System.out.println(milk + " ml of milk");
- // System.out.println(beans + " g of beans");
- // System.out.println("Specify the amount of water in the coffee machine in ml's:");
- // int waterAmount = input.nextInt();
- // System.out.println("Specify the amount of milk in the coffee machine in ml's:");
- // int milkAmount = input.nextInt();
- // System.out.println("Specify the amount of coffee beans in the coffee machine in grams:");
- // int beansAmount = input.nextInt();
- // System.out.println("How many cups of coffee will you need?");
- // int cupsAmount = input.nextInt();
- //
- // int cupsPossible = 0;
- // while (waterAmount >= 200 && milkAmount >= 50 && beansAmount >= 15) {
- // cupsPossible++;
- // waterAmount = waterAmount - 200;
- // milkAmount = milkAmount - 50;
- // beansAmount = beansAmount - 15;
- // }
- // int additionalCups = cupsPossible - cupsAmount;
- //
- //
- // if (cupsPossible == cupsAmount) {
- // System.out.println("Yes, I can make that amount of coffee");
- // } else if (cupsPossible > cupsAmount) {
- // System.out.println("Yes, I can make that amount of coffee (and even " + additionalCups + " cup(s) more than that)");
- // } else {
- // System.out.println("No, I can make only " + cupsPossible + " cup(s) of coffee");
- // }
- int waterAmount = 400;
- int milkAmount = 540;
- int beansAmount = 120;
- int cupsAmount = 9;
- int money = 550;
- systemCheck(waterAmount, milkAmount, beansAmount, cupsAmount, money);
- System.out.println("Write action (buy, fill, take): ");
- String action = input.next();
- switch (action){
- case "buy":
- buyDrink(waterAmount, milkAmount, beansAmount, cupsAmount, money);
- break;
- case "fill":
- fillMachine();
- break;
- case "take":
- getCash();
- break;
- default:
- System.out.println("Wrong choice!");
- }
- systemCheck(waterAmount, milkAmount, beansAmount, cupsAmount, money);
- }
- public static void systemCheck(int water, int milk, int beans, int cups, int money){
- System.out.println("The coffee machine has: ");
- System.out.println(water + " of water");
- System.out.println(milk + " of milk");
- System.out.println(beans + " of coffee beans");
- System.out.println(cups + " of disposable cups");
- System.out.println(money + " of money");
- }
- public static int[] buyDrink(int water, int milk, int beans, int cups, int money){
- Scanner in = new Scanner(System.in);
- System.out.println("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino: ");
- int choice = in.nextInt();
- switch (choice) {
- case 1:
- if (water >= 250 && beans >= 16 && cups > 0){
- water = water - 250;
- beans = beans - 16;
- money = money + 4;
- cups = cups - 1;
- }else
- System.out.println("Not enough ingredients, fill the machine please");
- break;
- case 2:
- if (water >= 350 && milk >= 75 && beans >= 20 && cups > 0){
- water = water - 350;
- milk = milk - 75;
- beans = beans - 20;
- money = money + 7;
- cups = cups - 1;
- } else
- System.out.println("Not enough ingredients, fill the machine please");
- break;
- case 3:
- if (water >= 200 && milk >= 100 && beans >= 12 && cups > 0){
- water = water - 200;
- milk = milk - 100;
- beans = beans - 12;
- cups = cups - 1;
- } else
- System.out.println("Not enough ingredients, fill the machine please");
- break;
- default:
- System.out.println("Wrong choice!");
- }
- return new int[] {water, milk, beans, money, cups};
- }
- public static void fillMachine(){
- }
- public static void getCash(){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement