galinyotsev123

ProgBasics04Nested-Statements-P04fruitOrVegetable

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