Advertisement
Guest User

CookieFactory

a guest
Mar 25th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.  
  7.         int batches = Integer.parseInt(input.nextLine());
  8.  
  9.         for (int i = 1; i <= batches; i++) {
  10.             String command = input.nextLine();
  11.             int a = 0;
  12.             int b = 0;
  13.             int c = 0;
  14.             while (true) {
  15.                 if (!command.equalsIgnoreCase("bake!")) {
  16.                     if (command.equalsIgnoreCase("flour")) {
  17.                         a++;
  18.                     }
  19.                     if (command.equalsIgnoreCase("eggs")) {
  20.                         b++;
  21.                     }
  22.                     if (command.equalsIgnoreCase("sugar")) {
  23.                         c++;
  24.                     }
  25.                 } else {
  26.                     if (a == 0 || b == 0 || c == 0) {
  27.                         System.out.printf("The batter should contain flour, eggs and sugar!%n");
  28.                     } else {
  29.                         System.out.printf("Baking batch number %d...%n", i);
  30.                         if (i == batches) return;
  31.                         break;
  32.                     }
  33.                 }
  34.                 command = input.nextLine();
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement