Advertisement
desislava_topuzakova

Untitled

May 8th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FruitOrVegetable__06 {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner (System.in);
  6. String kind = scan.nextLine();
  7. //да напишем програма която проверява дали е плод или зеленчук;
  8. //плодовете са banana, apple, kiwi, cherry, lemon and grapes;
  9. //зеленчуците са tomato, cucumber, pepper and carrot;
  10.  
  11. if (kind.equals("banana") || kind.equals("apple") || kind.equals("kiwi") || kind.equals("cherry") ||
  12. kind.equals("lemon") || kind.equals("grapes")){
  13. System.out.println("fruit");
  14. } else if ("tomato".equals(kind) || "cucumber".equals(kind) || "pepper".equals(kind) || "carrot".equals(kind)){
  15. System.out.print("vegetable");
  16. } else {
  17. System.out.print("unknown");
  18. }
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement