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 input = new Scanner(System.in);
- int batches = Integer.parseInt(input.nextLine());
- for (int i = 1; i <= batches; i++) {
- String command = input.nextLine();
- int a = 0;
- int b = 0;
- int c = 0;
- while (true) {
- if (!command.equalsIgnoreCase("bake!")) {
- if (command.equalsIgnoreCase("flour")) {
- a++;
- }
- if (command.equalsIgnoreCase("eggs")) {
- b++;
- }
- if (command.equalsIgnoreCase("sugar")) {
- c++;
- }
- } else {
- if (a == 0 || b == 0 || c == 0) {
- System.out.printf("The batter should contain flour, eggs and sugar!%n");
- } else {
- System.out.printf("Baking batch number %d...%n", i);
- if (i == batches) return;
- break;
- }
- }
- command = input.nextLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement