Well I was reading this in bed on my windows phone and it was bugging me. So now I am up late at night typing this!
The problem is you are reading in currency as a string which will contain USD, GBP:
currency = Console.ReadLine();
And reading amount in as a string and converting to a double - for example 300.0:
amount = double.Parse(Console.ReadLine());
You are then using both variables in a multiplication to get the converted amount:
Console.WriteLine("You have entered {0} EUR which converts to {1} {2}", amount, amount * currency, currency);
With amount * currency.
You have 2 types which cannot be multiplied together. String and Double! Thus you get a design-time error. Which you will see in the Visual Studio errors window:
Error 1 Operator '*' cannot be applied to operands of type 'double' and 'string'
You basically want to take the entered currency which is "USD", "GBP" and get the appropriate conversion factor from the variable you have named USD or GBP.
So in order to make your code "work" you need to do something like as follows:
switch (currency)
{
case "USD":
Console.WriteLine("You have entered {0} EUR which converts to {1} {2}", amount, amount * USD, currency); // <-- here is the change
break;
...
}
In the switch... case you know what the currency value is. The above is case "USD" so you need to reference the USD variable.
To make your code better, get rid of that switch. I would prefer a Dictionary where you could essentially store your strings (GBP, USD, etc) and have an associated conversion factor with each. But you would be getting introduced to the world of generics, but just get a grasp of some of the basics would be your best introduction to programming. But here you go!
double amount;
/* Dont need to declare these explicitly!
double USD = 1.39;
double GBP = .82;
double CHF = 1.22;
double AUD = 1.48;
double CAD = 1.51;*/
string currency;
Dictionary<string, double> factors = new Dictionary<string, double>();
factors.Add("GBP", 0.82D);
factors.Add("USD", 1.39D);
// ... add other factors
Console.WriteLine("Please enter the amount of Euro you wish to be converted:");
amount = double.Parse(Console.ReadLine());
Console.WriteLine("");
Console.WriteLine("Please choose the currency you wish to convert to:");
Console.WriteLine("USD");
Console.WriteLine("GBP");
Console.WriteLine("CHF");
Console.WriteLine("AUD");
Console.WriteLine("CAD");
Console.WriteLine("");
currency = Console.ReadLine();
double factor;
if (factors.TryGetValue(currency, out factor))
{
Console.WriteLine("You have entered {0} EUR which converts to {1} {2}", amount, amount * factor, currency);
}
else
{
Console.WriteLine("You did not enter a recognised currency {1}", currency);
}