#include #include /* predefined exchange rates */ #define - TopicsExpress



          

#include #include /* predefined exchange rates */ #define usd_to_euro 0.77 #define usd_to_aus 0.96 #define usd_to_yen 95.90 void determine_currency(int); void convert_currency(float,float); int main() { //float usd_amount; /* USD amount*/ int currency; printf("1 - Euro: (%.2f)",usd_to_euro); printf(" 2 - Australia Dollar: (%.2f)",usd_to_aus); printf(" 3 - Japanese Yen: (%.2f)",usd_to_yen); printf(" 4 - Other "); printf(" Please choose the currency: "); scanf("%d",¤cy); determine_currency(currency); getch(); } void determine_currency(int curr) { float rate, usd_amount; /* Enter amount in USD */ printf("Please enter USD amount: "); scanf("%f",&usd_amount); /* determine the rate */ if(curr == 1) rate = usd_to_euro; else if(curr == 2) rate = usd_to_aus; else if(curr == 3) rate = usd_to_yen; else { printf("Enter the exchange rate USD -> Foreign Currency: "); scanf("%f",&rate); } convert_currency(rate,usd_amount); } void convert_currency(float rate, float usd_amount) { float fc_amount; /* Convert currency */ if(rate > 0) { fc_amount = usd_amount * rate; } else { fc_amount=0; } printf("Result: %.2f",fc_amount); }
Posted on: Mon, 29 Jul 2013 11:44:41 +0000

Trending Topics



Recently Viewed Topics




© 2015