desislava_topuzakova

10. Invalid Number

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