Question #180654

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. DOLLAR 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;
using System.Linq;
using System.Text;


namespace Q180654
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter the currency value: ");
            double currencyValue = double.Parse(Console.ReadLine());
            Console.Write("Enter the name of the country: ");
            string countryName = Console.ReadLine();
            double dollars=-1;
            if (countryName.ToLower()=="British Pound".ToLower()){
                dollars = currencyValue/0.6;
            }
            else if (countryName.ToLower() == "Canadian Dollar".ToLower())
            {
                dollars = currencyValue / 1.3;
            }
            else if (countryName.ToLower() == "Japanese Yen".ToLower())
            {
                dollars = currencyValue/140;
            }
            else if (countryName.ToLower() == "German Mark".ToLower())
            {
                dollars = currencyValue/1.7;
            }
            else if (countryName.ToLower() == "Philippines Peso".ToLower())
            {
                dollars = currencyValue / 53 ;
            }
            else
            {
                Console.WriteLine("Error: wrong country name. Enter as this example: \"Canadian Dollar\"");
            }
            if (dollars != -1) {
                Console.WriteLine("The equivalent in U.S. dollar: {0}", dollars.ToString("C"));
            }
            Console.ReadLine();
        }
    }
}

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