Code:
#include <stdio.h>
#include <conio.h>
main()
{
/* Define Variables */
int option, option2;
float eur_sterling, sterling_eur, sterling, sterling_euro;
float eur_krone, krone_eur, krone, krone_euro;
float eur_yen, yen_eur, yen, yen_euro;
float euro_dollar1, euro_dollar2, euro_dollar;
float dollar_eur1, dollar_eur2, dollar_euro;
/* Start loop */
do
{
/* Display menu asking user to select a country or quit */
printf("Euro Currency Converter\n");
printf("1. Britain\n");
printf("2. Denmark\n");
printf("3. Japan\n");
printf("4. USA\n");
printf("5. Exit Program\n");
printf("Please select an option: ");
scanf("%d", &option);
/* Initiate if statement for 1. Britain */
if (option == 1)
{
/* Ask user if converting Euro to Sterling or vice versa */
printf("If converting from Euro to Sterling, press 1\n");
printf("If converting from Sterling to Euro, press 2\n");
scanf("%d", &option2);
if (option2 == 1)
{
/* Ask user to enter amount for conversion */
printf("Please enter the amount you wish to convert (Euro to Sterling): ");
scanf("%f", &eur_sterling);
/* Calculate Exchange rate from Euro to Sterling */
sterling = eur_sterling * 0.70;
printf("%.2f Euro = %.2f Sterling\n\n", eur_sterling, sterling);
}
else if (option2 == 2)
{
/* Ask user to enter amount for conversion */
printf("Please enter the amount you wish to convert (Sterling to Euro): ");
scanf("%f", &sterling_eur);
/* Calculate Exchange rate from Sterling to Euro */
sterling_euro = sterling_eur * 1.42;
printf("%.2f Sterling = %.2f Euro\n\n", sterling_eur, sterling_euro);
}
else
{
printf("Error: Invalid Code\n\n");
}
}
/* Initiate else if statement for 2. Denmark */
else if (option == 2)
{
/* Ask user if converting Euro to Krone or vice versa */
printf("If converting from Euro to Krone, press 1\n");
printf("If converting from Krone to Euro, press 2\n");
scanf("%d", &option2);
if (option2 == 1)
{
/* Ask user to enter amount for conversion */
printf("Please enter the amount you wish to convert (Euro to Krone): ");
scanf("%f", &eur_krone);
/* Calculate Exchange rate from Euro to Krone */
krone = eur_krone * 7.45;
printf("%.2f Euro = %.2f Krone\n\n", eur_krone, krone);
}
else if (option2 == 2)
{
/* Ask user to enter amount for conversion */
printf("Please enter the amount you wish to convert (Krone to Euro): ");
scanf("%f", &krone_eur);
/* Calculate Exchange rate from Krone to Euro */
krone_euro = krone_eur * 0.13;
printf("%.2f Krone = %.2f Euro\n\n", krone_eur, krone_euro);
}
else
{
printf("Error: Invalid Code\n\n");
}
}
/* Initiate else if statement for 3. Japan */
else if (option == 3)
{
/* Ask user if converting Euro to Yen or vice versa */
printf("If converting from Euro to Yen, press 1\n");
printf("If converting from Yen to Euro, press 2\n");
scanf("%d", &option2);
if (option2 == 1)
{
/* Ask user to enter amount for conversion */
printf("Please enter the amount you wish to convert (Euro to Yen): ");
scanf("%f", &eur_yen);
/* Calculate Exchange rate from Euro to Yen */
yen = eur_yen * 138;
printf("%.2f Euro = %.2f Yen\n\n", eur_yen, yen);
}
else if (option2 == 2)
{
/* Ask user to enter amount for conversion */
printf("Please enter the amount you wish to convert (Yen to Euro): ");
scanf("%f", ¥_eur);
/* Calculate Exchange rate from Yen to Euro */
yen_euro = yen_eur * 0.01;
printf("%.2f Yen = %.2f Euro\n\n", yen_eur, yen_euro);
}
else
{
printf("Error: Invalid Code\n\n");
}
}
/* Initiate else if statement for 4. USA */
else if (option == 4)
{
/* Ask user if converting Euro to Dollar or vice versa */
printf("If converting from Euro to Dollar, press 1\n");
printf("If converting from Dollar to Euro, press 2\n");
scanf("%d", &option2);
if (option2 == 1)
{
/*Ask user to enter exchange rate from Euro to Dollar */
printf("Please enter the exchange rate (1 Euro = ? Dollar): ");
scanf("%f", &euro_dollar1);
/* Ask user to enter amount for conversion */
printf("Please enter the amount you wish to convert (Euro to Dollar): ");
scanf("%f", &euro_dollar2);
/* Calculate Exchange rate from Euro to Dollar */
euro_dollar = euro_dollar1 * euro_dollar2;
printf("%.2f Euro = %.2f Dollar\n\n", euro_dollar2, euro_dollar);
}
else if (option2 == 2)
{
/*Ask user to enter exchange rate from Dollar to Euro */
printf("Please enter the exchange rate (1 Dollar = ? Euro): ");
scanf("%f", &dollar_eur1);
/* Ask user to enter amount for conversion */
printf("Please enter the amount you wish to convert (Dollar to Euro): ");
scanf("%f", &dollar_eur2);
/* Calculate Exchange rate from Dollar to Euro */
dollar_euro = dollar_eur1 * dollar_eur2;
printf("%.2f Dollar = %.2f Euro\n\n", dollar_eur2, dollar_euro);
}
else
{
printf("Error: Invalid Code\n\n");
}
}
else if (option == 5)
{
printf("Exit Program\n");
}
/* If neither options 1-5 were selected print Error */
else
{
printf("Error: Invalid Code\n\n");
}
}
while (option != 5);
/* End loop */
getch();
return 0;
} //End main