Hi. I'm not having a big problem. just curious why it wont work. It will convert yen and pounds to dollars but when i enter a number followed by the letter e for euros it wont work. if i change the program to enter say 't' for euros it will work just fine. anybody know why this is?
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
usingnamespace std;
inlinevoid keep_window_open() {char ch; cin >> ch;}
// conversion program to convert yen, euros, and pounds to dollars
int main()
{
constdouble yen_per_dollar = 0.010196; // yen per dollar
constdouble euro_per_dollar = 1.3231; // euros per dollar
constdouble pound_per_dollar = 1.4247; // pounds per dollar
double currency = 1;
char unit = ' ';
cout << "Please enter number of yen(y), euros(e), or pounds(p) followed by given unit to convert to U.S. dollars: ";
cin >> currency >> unit;
if (unit == 'y')
cout << currency << " Japanese yen = " << yen_per_dollar*currency << " U.S. dollars\n";
elseif (unit == 'e')
cout << currency << " Euros = " << euro_per_dollar*currency << " U.S. dollars\n";
elseif (unit == 'p')
cout << currency << " British pounds = " << pound_per_dollar*currency << " U.S. dollars\n";
else
cout << "Sorry, I don't know a unit you called '" << unit << "'\n";
}