/*
Génesis M Ojeda Rosa
COMP 3800
lenguaje COMP
Conversión de dólares a pesos colombianos, yen y euros.
*/
//imports library
#include <stdio.h>
//defines constants
#define COLOMBIAN_DOLLARS 4215
#define EUROS 0.93
#define YEN 143.86
int main() {
double us_dollars, colombian_dollars, euros, yen;
int choice, control = 1;
do {
// Display the menu of conversion
printf("Currency Converter Menu:\n");
printf("1. Convert to Colombian Pesos\n");
printf("2. Convert to Euros\n");
printf("3. Convert to Yen\n");
printf("4. Exit program\n");
printf("Enter your choice: ");
scanf("%d", &choice);
if (choice < 1 || choice > 4) {
printf("\nPlease enter a choice from the menu.\n");
continue; // Continues loop if the choice is invalid.
} else if (choice == 4) {
control = 0;
} else {
// Asks for the amount
printf("Enter USD amount to convert: ");
scanf("%lf", &us_dollars);
// Perform the conversion based on the choice
if (choice == 1) {
colombian_dollars = COLOMBIAN_DOLLARS * us_dollars;
printf("%.2f USD is %.2f Colombian Pesos\n", us_dollars, colombian_dollars);
} else if (choice == 2) {
euros = EUROS * us_dollars;
printf("%.2f USD is %.2f Euros\n", us_dollars, euros);
} else {
yen = YEN * us_dollars;
printf("%.2f USD is %.2f Yen\n", us_dollars, yen);
}
printf("\nDo you wish to continue? (0 = no, 1 = yes)\n");
scanf("%d", &control);
while (control != 0 && control != 1) {
printf("Please, enter 0 for 'no' and 1 for 'yes'\n");
scanf("%d", &control);
}
}
} while (control == 1);
return 0;
}