Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P08cookieFactory {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int numBatch = Integer.parseInt(scanner.nextLine());
- int countBath = 1;
- int countFlour = 0;
- int countEggs = 0;
- int countSugar = 0;
- while (countBath <= numBatch) {
- String component = scanner.nextLine();
- switch (component) {
- case "flour":
- countFlour++;
- break;
- case "eggs":
- countEggs++;
- break;
- case "sugar":
- countSugar++;
- break;
- case "Bake!":
- if ((countFlour + countEggs + countSugar) < 3) {
- System.out.println("The batter should contain flour, eggs and sugar!");
- } else {
- System.out.printf("Baking batch number %d...%n", countBath);
- countBath++;
- countFlour = 0;
- countEggs = 0;
- countSugar = 0;
- }
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment