Advertisement
desislava_topuzakova

09. Fruit or Vegetable

Jun 19th, 2021
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 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.         //else -> unknown
  10.  
  11.         if (product.equals("banana") || product.equals("apple") || product.equals("kiwi") ||
  12.             product.equals("cherry") || product.equals("lemon") || product.equals("grapes")) {
  13.             System.out.println("fruit");
  14.         } else if (product.equals("tomato") || product.equals("cucumber") || product.equals("pepper") ||
  15.                    product.equals("carrot")) {
  16.             System.out.println("vegetable");
  17.         } else {
  18.             System.out.println("unknown");
  19.         }
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement