Xadez

Fruit or vegetable

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