C++自学新手关于if语句的问题。请各位不吝赐教!
这是一道出自《C++程序设计原理与实践》的习题。

前面的示例程序主要讲了if语句的用法。
我的想法是这样的:
可是当我输入100 JPY或EUR时得出的结果却是这样的:

请问错在哪里?谢谢!
P.s.祝大家马年快乐!

前面的示例程序主要讲了if语句的用法。
我的想法是这样的:
int main()
{
cout << "Please enter the amount and kind of currency: ";
const double jpy_per_usd = 0.0099;
const double eur_per_usd = 1.3519;
const double gbp_per_usd = 1.6274;
double amount;
char kind;
cin >> amount >> kind;
if (kind == 'JPY')
{
cout << amount << " JPY= " << amount*jpy_per_usd << " dollars.\n";
}
else if (kind == 'EUR')
{
cout << amount << " EUR= " << amount* eur_per_usd << " dollars.\n";
}
else
cout << amount << " GBP= " << amount*gbp_per_usd << " dollars.\n";
}可是当我输入100 JPY或EUR时得出的结果却是这样的:

请问错在哪里?谢谢!
P.s.祝大家马年快乐!
...全文


新手乐园
