Advertisement
desislava_topuzakova

09. Fruit or Vegetable

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