Answer to Question #325784 in C# for chi

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


1
Expert's answer
2022-04-08T03:47:45-0400
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS