Advertisement
Guest User

Untitled

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