DEV Community

Ivan Ivanov
Ivan Ivanov

Posted on

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

Top comments (0)