I'm currently using switch statements with c++, I worked through some examples and used an independent example to finish with. The example I chose was a currency converter from eur to gbp. In all cases, my code reverted to the default as if the wrong unit was input. This happened until I changed my input from the '€ symbol or '£' symbol to 'E' or 'P'. I'd like to know where I went wrong. an example of my code is below.
// Currency: Convert GBP to EUR or Vice Versa
int main(){
double gbp_to_eur = 1.09;
double eur_to_gbp = 0.92;
char unit = '£';
double amount_to_convert = 0;
int AnyKey = 0;
cout << "Please enter the the unit you'd like to convert \n";
cin >> unit;
cout << "\n \n Now please enter the amount you'd like to convert. \n";
cin >> amount_to_convert;
switch (unit) {
case 'P':
cout << "Your " << unit << amount_to_convert << " is worth €" << amount_to_convert * gbp_to_eur << '.\n';
break;
case 'E':
cout << "Your " << unit << amount_to_convert << " is worth €" << amount_to_convert * eur_to_gbp << '.\n';
break;
default: cout << "The compiler isn't programmed for this unit of currency. \n";
break;
}
cin >> AnyKey;
}