I have tried to compile. Need for project. It is supposed to provide error message, but just sits there. Does anyone see what the problem is?
Code:/*Library for program functions*/ #include <stdio.h> /* This declares the atoffunction*/ double atof(char *); /*Main Function*/ int main (void) { /*Declaration of Currency Conversions*/ int choice; float money; float total; char ch; char input[10]; int idx, decimal_found ; /*Declaration of conversion rates retrieved October 6,2005 on http://www.xe.com/ucc/ and Print*/ printf("\n\nCURRENCY CONVERSION\n"); printf("1. British Pound 0.56767=1 U.S. Dollar\n"); printf("2. Euro 0.83598 =1 U.S. Dollar\n"); printf("3. Japanese Yen 114.000=1 U.S. Dollar\n"); printf("4. Mexican Peso 10.71900=1 U.S. Dollar\n"); printf("5. Russian Ruble 28.56000=1 U.S. Dollar\n"); printf("Enter the number for the currency to convert..."); /*Prompt user for Type of Currency */ printf("\n\n Please Select the Currency you would like to convert (1-5): "); scanf("%d",&choice); fflush(stdin); { char ch; char input[10]; int idx, decimal_found ; } printf("\n\n Please enter a dollar amount you would like to convert. (US Dollars): "); scanf("%f",&money); decimal_found = 0 ; /*Checks for validity of input entered by user for numerical value,retreived from Aruna Pandey*/ for (idx = 0 ; idx < strlen(input) ; idx++) { if (input[idx] == '.') { // check if more than one decimal character has been entered? // if the decimal character was found earlier, the "decimal_found" // flag will be equal to 1. At this time, this is an invalid entry. // so exit immediately. // if (decimal_found == 1) break ; else decimal_found = 1 ; } else { if (input[idx] < 48 || input[idx] > 57) break ; } } /*Checks for non numeric character*/ if (idx < strlen(input)) { /*Prints response for invalid entry*/ printf("Invalid Entry. Please Try Again.\n"); } else { /* converts user input to a float value*/ &money = atof(input); /*Returns Selected Choice with Currency Conversion*/ } if(choice == 1) { total = money * 0.56767; printf("\n\nYou will have %f British Pounds \n\n", total); } if(choice == 2) { total = money * 0.83598; printf("\n\nYou will have %f Euro \n\n", total); } if(choice == 3) { total = money * 114.000; printf("\n\nYou will have %f Japansese Yen \n\n",total); } if(choice == 4) { total = money * 10.71900; printf("\n\nYou will have %f Mexican Pesos \n\n", total); } if(choice == 5) { total = money * 28.56000; printf("\n\nYou will have %f Russian Ruble \n\n", total); } getchar(); /*normal program end*/ return 0; }



LinkBack URL
About LinkBacks


