Sunday, March 16, 2014

Switch_Structure_Ex_1: (Wk-4), Jan 27-31, 2014

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Switch_Structure_Ex_1
{
    class Program
    {
        static void Main(string[] args)
        {
        repeat:
            Console.WriteLine("Choose your best hobby: ");
            Console.WriteLine("\t1. Reading");
            Console.WriteLine("\t2. Playing Tennis");
            Console.WriteLine("\t3. Watching Movies");
            Console.WriteLine("\t4. Fishing");
            Console.WriteLine("\t5. Running");
          
            Console.Write("\nEnter your hobby: ");
            int selection = int.Parse(Console.ReadLine());

            switch (selection)
            {
                case 1:
                    {
                        Console.WriteLine("\n\tYou like Reading");
                    }
                    break;
                case 2:
                    {
                        Console.WriteLine("\n\tYou like Playing Tennis");
                    }
                    break;
                case 3:
                    {
                        Console.WriteLine("\n\tYou like Watching Movies");
                    }
                    break;
                case 4:
                    {
                        Console.WriteLine("\n\tYou like Fishing");
                    }
                    break;
                case 5:
                    {
                        Console.WriteLine("\n\tYou like Running");
                    }
                    break;
                default:
                    {
                        Console.WriteLine("Sorry, Invalid Selection");
                    }
                    break;
            }
            Console.ReadLine();
            Console.Clear();
            goto repeat;
        }
    }
}

No comments:

Post a Comment