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
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;
}
}
}
}
Comments
Leave a comment