Advertisement
desislava_topuzakova

9. Fruit or Vegetable

Nov 12th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class demo {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. //1. входни данни
  7. String product = scanner.nextLine();
  8.  
  9. //fruit -> banana, apple, kiwi, cherry, lemon и grapes
  10. //vegetable -> tomato, cucumber, pepper и carrot
  11. //other ->
  12.  
  13. if (product.equals("banana") || product.equals("apple")
  14. || product.equals("kiwi") || product.equals("cherry")
  15. || product.equals("lemon") || product.equals("grapes")) {
  16. System.out.println("fruit");
  17. } else if (product.equals("tomato") || product.equals("cucumber")
  18. || product.equals("pepper") || product.equals("carrot")) {
  19. System.out.println("vegetable");
  20. } else {
  21. System.out.println("unknown");
  22. }
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement