Today, I wrote a short paragraph about the Japanese yen, the euro against the United States dollar exchange rate of the procedure, encountered a very interesting thing, do not want to be happy, send out to share with everyone.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
const double usd_per_jpy=76.7620;
const double usd_per_eur=0.7248;
Double money;
string symble;
cout<< "Please input the money by the Symble (JPY/EUR/USD):" <<endl;
cin>>money>>symble;
if (symble== "JPY") {
cout<<money<< "jpy=" <<money/usd_per_jpy<< "USD" <<endl;
}
else if (symble== "EUR") {
cout<<money<< "eur=" <<money/usd_per_eur<< "USD" < <endl;
}
else {
cout<< "Sorry, plese check the symble you ' ve input!" <<endl;
}
System ("pause");
}
The program runs normally. When you enter 20JPY again, the output
But in the input 10eur, an interesting thing happened, initially thought that their code is wrong, but after several checks, the code is not a problem.
Later, after a meditation, it dawned. Originally in the input 10eur, the computer will 10eur default to 10e ur, so cause error.
Later verified, will be EUR to ur after running again, all normal. It seems that in the future in some of the details still need to pay more attention. But the more I find programming interesting. adhere to ~ ~ ~ Wish everyone happy. Thank you ~ ~ ~