desislava_topuzakova

9. Плод или зеленчук?

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