Advertisement
veronikaaa86

09. Fruit or Vegetable

Nov 13th, 2021
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package advancedConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P09FruitOrVegetable {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String product = scanner.nextLine();
  10.  
  11. // • Плодовете "fruit" са banana, apple, kiwi, cherry, lemon и grapes
  12. // • Зеленчуците "vegetable" са tomato, cucumber, pepper и carrot
  13.  
  14. switch (product) {
  15. case "banana":
  16. case "apple":
  17. case "kiwi":
  18. case "cherry":
  19. case "lemon":
  20. case "grapes":
  21. System.out.println("fruit");
  22. break;
  23. case "tomato":
  24. case "cucumber":
  25. case "pepper":
  26. case "carrot":
  27. System.out.println("vegetable");
  28. break;
  29. default:
  30. System.out.println("unknown");
  31. }
  32.  
  33. }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement