Question #185305

7. Write a program using string functions that will accept the name of the capital as input value and will display the corresponding country. CAPITALS COUNTRIES Ottawa Canada Washington D.C. United States Moscow Russia Rome Italy Manila Philippines


Expert's answer

using System;

namespace Test
{
    class CapitalTest
    {
        static void Main()
        {
            Console.Write("Enter the name of the capital: ");
            string capital = Console.ReadLine();
            Console.Write("The country: ");

            switch(capital)
            {
                case "Ottawa":          Console.WriteLine("Canada");          break;
                case "Washington D.C.": Console.WriteLine("United States");   break;
                case "Moscow":          Console.WriteLine("Russia");          break;
                case "Rome":            Console.WriteLine("Italy");           break;
                case "Manila":          Console.WriteLine("Philippines");     break;
                default:                Console.WriteLine("Unknown capital"); break;
            }
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS