I am new to c++ and working through the book'Programming principles and practice using c++'
I am asked to write a program to convert 3 currencies into dollars. I have written the program and it works perfectly for 2 of the currencies, but it wont work for the third (Euros) and I have no idea why.
I'm sure it is something very simple that I am missing, but would love the help! Would also welcome any critique on my code.
#include <iostream>
using namespace std;
int main(){
constexpr double yen_to_dollars=0.0091;
constexpr double euro_to_dollars=1.071;
constexpr double pound_to_dollars=1.279;
double amount=1;
char currency =' ';
cout<<"please enter an amount of currency to be converted to dollars (Y, E or P):\n";
cin >> amount >> currency;
if(currency=='Y')
cout<<amount<<"Yen = " << yen_to_dollars*amount << "dollars\n";
else if(currency=='P')
cout<<amount<<"Pounds = "<<pound_to_dollars*amount << "dollars\n";
else if(currency='E')
cout<<amount<<"Euros = "<<euro_to_dollars*amount << "dollars\n";
else
cout<<"That is an invalid currency\n";
}