这个 C 语言问题要怎么回答 If you can help me,please write down your program.Thanks!Write the program rates which should convert Macau Patacas into following four currencies:USD,HKD,RMB,Euro.The program should receive a Pataca amount from t
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/01 07:00:40
这个 C 语言问题要怎么回答 If you can help me,please write down your program.Thanks!Write the program rates which should convert Macau Patacas into following four currencies:USD,HKD,RMB,Euro.The program should receive a Pataca amount from t
这个 C 语言问题要怎么回答 If you can help me,please write down your program.Thanks!
Write the program rates which should convert Macau Patacas into following four currencies:USD,HKD,RMB,Euro.The program should receive a Pataca amount from the user and print the equivalent rate in the other currencies.The program should have one function for each currency that Patacas are converted into; so it should have the functions mop_usd,mop_hkd,mop_rmb,and mop_euro.These functions should receive an amount in Patacas as input,and produce the converted amount as their return value.Your program should use following exchange rates (amount in foreign currency for 1 Macau Pataca):
Currency Rate
USD 0.12503
HKD 0.96946
RMB 0.83502
Euro 0.09225
Define the exchange rates as constants in your program using #define statements (macros).
Example:
Currency exchange rates for Macau Patacas (MOP)
Enter amount in MOP:650
650.00 MOP is equivalent to:
USD 81.27
HKD 630.15
RMB 542.76
Euro 59.96
这个 C 语言问题要怎么回答 If you can help me,please write down your program.Thanks!Write the program rates which should convert Macau Patacas into following four currencies:USD,HKD,RMB,Euro.The program should receive a Pataca amount from t
#include
#include
#define USD 0.12503
#define HKD 0.96946
#define RMB 0.83502
#define EURO 0.09225
float mop_usd(float);
float mop_hkd(float);
float mop_rmb(float);
float mop_euro(float);
int main(void)
{
float mop;
printf("Currency exchange rates for Macau Patacas (MOP)\n");
printf("Eneter amount in MOP:");
scanf("%f",&mop);
printf("%f MOP is equivalent to:\n",mop);
printf("USD %.2f\n",mop_usd(mop));
printf("HKD %.2f\n",mop_hkd(mop));
printf("RMB %.2f\n",mop_rmb(mop));
printf("EURO %.2f\n",mop_euro(mop));
return 0;
}
float mop_usd(float mop)
{
return mop*USD;
}
float mop_hkd(float mop)
{
return mop*HKD;
}
float mop_rmb(float mop)
{
return mop*RMB;
}
float mop_euro(float mop)
{
return mop*EURO;
}
你要的应该是这个样子的.