Answer to Question #185383 in C# for angelo r reyes

Question #185383

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-28T02:48:54-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace C_SHARP
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] countryNames = { "British Pound", "Canadian Dollar", "Japanese Yen", "German Mark", "Philippines Peso" };
            double[] dollarFactors = { 0.6, 1.3, 140, 1.7, 53 };


            Console.Write("Enter the currency value: ");
            double userCurrency = double.Parse(Console.ReadLine());
            for (int i = 0; i < countryNames.Length; i++)
            { 
                Console.WriteLine("{0}. {1}",(i+1), countryNames[i]);
            }
            int selectedCountry=-1;
            while (selectedCountry < 1 || selectedCountry > countryNames.Length) {
                Console.Write("Select the country: ");
                selectedCountry = int.Parse(Console.ReadLine());
            }
            double dollars =userCurrency / dollarFactors[selectedCountry-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
APPROVED BY CLIENTS