9. Fruit or Vegetable (Switch Construction)

ivanitd

Ivan Ivanov

Posted on January 20, 2023

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

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

        switch (product)
        {
            case "banana":
            case "apple":
            case "kiwi":
            case "cherry":
            case "lemon":
            case "grapes":
                Console.WriteLine("fruit");
                break;

            case "tomato":
            case "cucumber":
            case "pepper":
            case "carrot":
                Console.WriteLine("vegetable");
                break;

            default:
                Console.WriteLine("unknown");
                break;
        }
    }
}
}
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