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
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();
}
}
}
Comments
Leave a comment