Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int bakingBatchCounter = 0;
- boolean eggs = false;
- boolean flour = false;
- boolean sugar = false;
- for (int i = 1; i <= n; i++) {
- String product = scanner.nextLine();
- while (!product.equalsIgnoreCase("bake!")) {
- if (product.equalsIgnoreCase("eggs")) {
- eggs = true;
- } else if (product.equalsIgnoreCase("flour")) {
- flour = true;
- } else if (product.equalsIgnoreCase("sugar")) {
- sugar = true;
- }
- product = scanner.nextLine();
- }
- if (eggs && flour && sugar) {
- eggs = false;
- flour = false;
- sugar = false;
- System.out.printf("Baking batch number %d...%n", i);
- } else {
- i--;
- System.out.println("The batter should contain flour, eggs and sugar!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement