Hi,
Thanks for all the help so far. Any more sugestions would be greatly appreciated.
Thanking you.
Code:#include <stdio.h> /* Define Constants for Currency Conversion Rates */ #define POUND 0.70 #define KRONE 7.43 #define YEN 127 int main() { /* Declare all varabials */ int menu_choice, error; float local_amount, remote_amount; float USD; do { /* Display Menu System */ /* 5 Options */ printf("1. Britain\n"); printf("2. Denmark\n"); printf("3. Japan\n"); printf("4. USA\n"); printf("5. Exit Program\n\n"); /* Ask user for there choice */ /* Asign the choice to varabial menu_choice, which is of int data type */ /* Keep Asking The User for input until they enter correct data */ /* This do loop will itterate until the user enteres the desired menu option to exit */ do { printf("Please Enter Your Country Selection From The Menu: \t"); error = scanf("%d",&menu_choice); fflush(stdin); } while ( error == 0 || menu_choice < 1 || menu_choice > 5 ); if (menu_choice == 1) { /* Ask user for there choice */ /* Asign the choice to varabial menu_choice, which is of int data type */ /* Keep Asking The User for input until they enter correct data */ printf("\n\nDo you wish to convert from:\n\n"); printf("1. Euro to Pound(Sterling)\n"); printf("2. Pound(Sterling) to Euro\n\n"); do { printf("Please Enter Your Choice From The Menu: \t"); error = scanf("%d",&menu_choice); fflush(stdin); } while ( error == 0 || menu_choice < 1 || menu_choice > 2 ); if (menu_choice == 1) { printf("\n\nEuro to Pound(Sterling):\n\n"); printf("Please Enter Euro Amount to be Converted: \t"); scanf("%f",&local_amount); remote_amount = local_amount * POUND; printf("\n%.2f Euro is equal to %.2f Pound\n\n",local_amount, remote_amount); menu_choice = 0; } if (menu_choice == 2) { printf("\n\nPound(Sterling) to Euro:\n\n"); printf("Please Enter Pound(Sterling) Amount to be Converted: \t"); scanf("%f",&local_amount); remote_amount = local_amount / POUND; printf("\n%.2f Pound is equal to %.2f Euro\n\n",local_amount, remote_amount); menu_choice = 0; } } if (menu_choice == 2) { printf("\n\nDo you wish to convert from:\n\n"); printf("1. Euro to Krone\n"); printf("2. Krone to Euro\n\n"); do { printf("Please Enter Your Choice From The Menu: \t"); error = scanf("%d",&menu_choice); fflush(stdin); } while ( error == 0 || menu_choice < 1 || menu_choice > 2 ); if (menu_choice == 1) { printf("\n\nEuro to Krone:\n\n"); printf("Please Enter Euro Amount to be Converted: \t"); scanf("%f",&local_amount); remote_amount = local_amount * KRONE; printf("\n%.2f Euro is equal to %.2f Krone\n\n",local_amount, remote_amount); menu_choice = 0; } if (menu_choice == 2) { printf("\n\nKrone to Euro:\n\n"); printf("Please Enter Krone Amount to be Converted: \t"); scanf("%f",&local_amount); remote_amount = local_amount / KRONE; printf("\n%.2f Krone is equal to %.2f Euro\n\n",local_amount, remote_amount); menu_choice = 0; } } if (menu_choice == 3) { printf("\n\nDo you wish to convert from:\n\n"); printf("1. Euro to Yen\n"); printf("2. Yen to Euro\n\n"); do { printf("Please Enter Your Choice From The Menu: \t"); error = scanf("%d",&menu_choice); fflush(stdin); } while ( error == 0 || menu_choice < 1 || menu_choice > 2 ); if (menu_choice == 1) { printf("\n\nEuro to Yen:\n\n"); printf("Please Enter Euro Amount to be Converted: \t"); scanf("%f",&local_amount); remote_amount = local_amount * YEN; printf("\n%.2f Euro is equal to %.2f Yen\n\n",local_amount, remote_amount); menu_choice = 0; } if (menu_choice == 2) { printf("\n\nYen to Euro:\n\n"); printf("Please Enter Yen Amount to be Converted: \t"); scanf("%f",&local_amount); remote_amount = local_amount / YEN; printf("\n%.2f Yen is equal to %.2f Euro\n\n",local_amount, remote_amount); menu_choice = 0; } } if (menu_choice == 4) { printf("\n\nDo you wish to convert from:\n\n"); printf("1. Euro to US Dollars\n"); printf("2. US Dollars to Euro\n\n"); do { printf("Please Enter Your Choice From The Menu: \t"); error = scanf("%d",&menu_choice); fflush(stdin); } while ( error == 0 || menu_choice < 1 || menu_choice > 2 ); printf("\nExample:\t\t1 EURO = POUND 0.70\n\t\t\t1 EURO = KRONE 7.43\n\n"); do { printf("Please Enter Current US Dollar Exchange Rate: \t"); error = scanf("%f",&USD); fflush(stdin); } while ( error == 0 || USD <= 0); if (menu_choice == 1) { printf("\n\nEuro to US Dollars:\n\n"); printf("Please Enter Euro Amount to be Converted: \t"); scanf("%f",&local_amount); remote_amount = local_amount * USD; printf("\n%.2f (EURO) is equal to %.2f (USD)\n\n",local_amount, remote_amount); menu_choice = 0; } if (menu_choice == 2) { printf("\n\nUS Dollars to Euro:\n\n"); printf("Please Enter US Dollar Amount to be Converted: \t"); scanf("%f",&local_amount); remote_amount = local_amount / USD; printf("\n%.2f (USD) is equal to %.2f (Euro)\n\n",local_amount, remote_amount); menu_choice = 0; } } if (menu_choice == 5) { printf("Thank You Come Again!"); } } while(menu_choice == 0); printf("\n\n\n\n\n\n$$$$ UP!"); return 0; }



LinkBack URL
About LinkBacks


