6.8.
Write a program that will accept the currency value and the name of the country and will
display the equivalent in U.S. dollar, based on the given list:
COUNTRY CURRENCY U.S EQUIVALENT
British Pound 0.6 U.S. dollar
Canadian Dollar 1.3 U.S. dollar
Japanese Yen 140 U.S. dollar
German Mark 1.7 U.S. dollar
Philippines Peso 53 U.S. dollar
using System;
using System.Collections.Generic;
namespace collection_dictionary
{
class Program
{
public static void Main(string[] args)
{
string str;
var currency = new Dictionary <string, double>()
{
{ "British Pound", 0.6},
{ "Canadian Dollar", 1.3},
{ "Japanese Yen", 140},
{ "German Mark", 1.7},
{ "Philippines Peso", 53}
};
Console.Write("Enter country and currency: ");
str = Console.ReadLine();
Console.WriteLine("{0} {1} U.S. dollar", str, currency[str]);
Console.Write("\nPress any key to continue . . . ");
Console.ReadKey(true);
}
}
}
Comments
Leave a comment