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 scanner = new Scanner(System.in);
- int batchesNum = Integer.parseInt(scanner.nextLine());
- for (int i = 1; i <= batchesNum; i++) {
- String product = scanner.nextLine();
- boolean flour = false;
- boolean eggs = false;
- boolean sugar = false;
- while (true) {
- if ("flour".equals(product)) {
- flour = true;
- }
- if ("eggs".equals(product)) {
- eggs = true;
- }
- if ("sugar".equals(product)) {
- sugar = true;
- }
- if ("Bake!".equals(product)) {
- if (flour && eggs && sugar == true) {
- System.out.printf("Baking batch number %d...%n", i);
- break;
- } else {
- System.out.println("The batter should contain flour, eggs and sugar!");
- }
- }
- product = scanner.nextLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement