Start New Discussion within our Software Development Community

Hey guys., i wrote a little program to calculate the foreign exchange of canadian dollar to french frank. but when i validate an input(it has to be between 1 and a 1000), i get a problem even though it makes user to reenter the number, still the very first number enter is used. any suggestions would be greatly appreciated!!


double GetAmount(void);
double AmountValidate(double amount);
double CalcAmount(double amount_c, double exchange_rate);
void PrintResults(double canadian_d, double french_f);


	double amount_c; double amount_f;
	double exchange_rate=3.528582;
	amount_f=CalcAmount(amount_c, exchange_rate);
	PrintResults(amount_c, amount_f);


double GetAmount(void)
	double amount;	
	printf("Hello, this program will convert CAD to French Franks\n");
	printf("The Exchange rate is 3.528582., Enter the amount in CAD:");
	scanf("%lf", &amount);
    return amount;

double AmountValidate(double amount_c)
	    while(amount_c < 1.0 || amount_c >1000.0)
          printf("Invalid Entry, Must be between 1 and 1000, Please Re-Enter:");
		  scanf("%lf", &amount_c);

    return amount_c;

double CalcAmount(double amount_c, double exchange_rate)

	double french_f;
	return french_f;

void PrintResults(double canadian_d, double french_f)
	printf("******* Foreign Exchange ********\n");
	printf("Canadian dollars: %.2lf\n", canadian_d);
	printf("French francs: %.2lf\n", french_f);

You don't reassign amount when you call AmountValidate from the main method.

This question has already been answered. Start a new discussion instead.