desislava_topuzakova

09. Fruit or Vegetable

Sep 25th, 2021
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 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. //others -> unknown
  10. if (product.equals("banana") || product.equals("apple")
  11. || product.equals("kiwi") || product.equals("cherry")
  12. || product.equals("lemon") || product.equals("grapes")) {
  13. System.out.println("fruit");
  14. } else if (product.equals("tomato") || product.equals("cucumber")
  15. || product.equals("pepper") || 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