# Thread: A simple currency conversion program gone south!!

1. ## A simple currency conversion program gone south!!

I am working on this conversion program that I have pieced together off the web as this is my first experience in programming in C. The concept of the program will eventually be converting foreign currency to U.S. dollars. As of now, I can convert the first amount (Pesos), however cannot convert the 2nd amount (Euros). I think there is an error in the first printf line that separates the two different currency amounts.

Any help would be appreciated.
Thanks.

Code:
```#include <stdio.h>

void print_converted(int dollars)
/* Converts from foreign country to U.S. currency*/
{	float dollars1 = dollars / (14.247);
float dollars2 = dollars / (0.7585);

printf("%5.2f\n",dollars1, dollars2);
}

main()

{

int us_peso,us_euro;
printf("Currency Conversion by RH v1.1\n\n\n"); /*Title */
printf("One U.S. Dollar = 14.247 Mexico Peso\n"); /*Prints currency for Mexico*/
printf("One U.S. Dollar = 0.7585 Euro\n");  /*Prints currency for countries that use the Euro*/
printf("One U.S. Dollar = 89.104 Japan Yen\n");/*Prints currency for Japan*/
printf("One U.S. Dollar = 0.7059 UK Pound\n");/*Prints currency for the United" Kingdom*/
printf("One U.S. Dollar = 173.50 Djibouti Franc\n\n\n");/*Prints currency for Djibouti (My current location)*/
printf("Give me a foreign currency amount  : ");

if (scanf("%d", &us_peso)!=1)
printf("Wrong!! You entered a character, please try again\n"); /* Error checker for a character */
else
{
if (us_peso<0)
printf("Wrong!! You entered a negetive number, please try again\n"); /* Error checker for a negetive number */
else	 {

printf("\nThank you!!\n\n");
printf("(Your %d Mexican Pesos) ", us_peso), printf(" ---->  (U.S. Dollars) = \$"),print_converted(us_peso); /*Prints conversion to US dollars */
printf("(Your %d Euros) ",us_peso), printf(" ------------>  (U.S. Dollars) = \$"),print_converted(us_euro); /*Prints conversion to US dollars */

}

}

}
/*	1.1 Currency Conversion, RH, 1/31/09; added the prompt for inputing amount*/
/*	1.0 Currency Conversion, RH, 1/28/09; initial version*/```

2. printf("%5.2f\n",dollars1, dollars2);

should be
Code:
`printf("%5.2f %5.2f\n",dollars1, dollars2);`
main()

should be
Code:
`int main(void)`