Answer to Question #185305 in C# for angelo r reyes

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


1
Expert's answer
2021-04-25T07:13:38-0400
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS