Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CookieFactory {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int batchesNum = Integer.parseInt(scanner.nextLine());
  7.  
  8. for (int i = 1; i <= batchesNum; i++) {
  9. String product = scanner.nextLine();
  10.  
  11. boolean flour = false;
  12. boolean eggs = false;
  13. boolean sugar = false;
  14.  
  15. while (true) {
  16. if ("flour".equals(product)) {
  17. flour = true;
  18. }
  19. if ("eggs".equals(product)) {
  20. eggs = true;
  21. }
  22. if ("sugar".equals(product)) {
  23. sugar = true;
  24. }
  25.  
  26. if ("Bake!".equals(product)) {
  27. if (flour && eggs && sugar == true) {
  28. System.out.printf("Baking batch number %d...%n", i);
  29. break;
  30. } else {
  31. System.out.println("The batter should contain flour, eggs and sugar!");
  32. }
  33. }
  34. product = scanner.nextLine();
  35. }
  36. }
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement