Advertisement
galinyotsev123

ProgBasicsJavaBook4.1ComplexConditions04FruitOrVegetable

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