Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FruitOrVegetable__06 {
- public static void main(String[] args) {
- Scanner scan = new Scanner (System.in);
- String kind = scan.nextLine();
- //да напишем програма която проверява дали е плод или зеленчук;
- //плодовете са banana, apple, kiwi, cherry, lemon and grapes;
- //зеленчуците са tomato, cucumber, pepper and carrot;
- if (kind.equals("banana") || kind.equals("apple") || kind.equals("kiwi") || kind.equals("cherry") ||
- kind.equals("lemon") || kind.equals("grapes")){
- System.out.println("fruit");
- } else if ("tomato".equals(kind) || "cucumber".equals(kind) || "pepper".equals(kind) || "carrot".equals(kind)){
- System.out.print("vegetable");
- } else {
- System.out.print("unknown");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement