該程序正常工作,但只有一個錯誤。它不會從歐元兌換爲美元,它只是給我輸出信息c編程時出錯
0.0歐元= 0.0美元;
你們能幫助我嗎?
#include <stdio.h>
#include <stdlib.h>
void dollar(float dollar);
int main()
{
char what;
int howmany;
int i;
float dollar2;
float euro2;
printf("enter how many times do you want to convert\n");
scanf(" %d", &howmany);
printf("enter U if you want to convert from USD to Euro\n");
printf("enter E if you want to convert from Euro to USD\n");
for(i=0; i<=howmany-1; i++)
{
scanf(" %c", &what);
if(what == 'E')
{
printf(" Enter how many euros do you want to convert\n");
scanf(" %f", &euro2);
euro(euro2);
}
if(what == 'U'){
printf(" Enter how many dollars do you want to convert\n");
scanf(" %f", &dollar2);
dollar(dollar2);
}
}
return 0;
}
void dollar(float dollar)
{
float euro = 0.94 * dollar;
printf("%0.2f dollar = %0.2f euro\n", dollar, euro);
return;
}
void euro(float euro)
{
float dollar = 1.37 * euro;
printf("%0.2f EURO = %0.2f DOLLAR\n", euro, dollar);
return;
}
你有什麼輸入? –
我第一次輸入4,然後它要求貨幣,所以我進入E這就是它 –
是的,它對美元工作正常,但不是歐元! –