Answer to Question #180654 in C# for Patrick Ian Kyle Mabunay

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


1
Expert's answer
2021-04-15T06:23:45-0400
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS