Question #325784

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


Expert's answer

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);
        }
    }
}

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