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