9. Fruit or Vegetable (If Construction)

ivanitd

Ivan Ivanov

Posted on January 20, 2023

9. Fruit or Vegetable (If Construction)
using System;

namespace FruitOrVegetable_If_
{
internal class Program
{
    static void Main(string[] args)
    {
        string product = Console.ReadLine();

        if (product == "banana" || product == "apple" || product == "kiwi" || product == "cherry" || product == "lemon" || product == "grapes")
        {
            Console.WriteLine("fruit");
        }
        else if (product == "tomato" || product == "cucumber" || product == "pepper" || product == "carrot")
        {
            Console.WriteLine("vegetable");
        }
        else
        {
            Console.WriteLine("unknown");
        }
    }
}
}
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
ivanitd
Ivan Ivanov

Posted on January 20, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

10. Invalid Number
csharp 10. Invalid Number

January 20, 2023

11. Fruit Shop (Switch Construction)
csharp 11. Fruit Shop (Switch Construction)

January 20, 2023