]> git repositories - AIO-converter.git/commitdiff
added list for currency converter
authorbochard <mail@bochard.net>
Sat, 19 Jul 2025 13:01:02 +0000 (21:01 +0800)
committerbochard <mail@bochard.net>
Sat, 19 Jul 2025 13:01:02 +0000 (21:01 +0800)
main.c

diff --git a/main.c b/main.c
index e7975e4e091e1e6cadc7c289ec365ca50d4724e5..6bedf0a2c713d1b23e7ee626215e448d2eb92860 100644 (file)
--- a/main.c
+++ b/main.c
@@ -36,7 +36,8 @@ char intro(){
   printf(" Welcome to the Basic Unit Converter! ");
   printf("%.*s", 10, "=================");
   printf("\nChoose one from the list:\n");
-  printf("(1)Temperature Converter\n(2)Currency Converter\n(3)Mass Converter\n");
+  printf("(1)Temperature Converter\t(2)Currency Converter\n");
+  printf("\t\t(3)Mass Converter\n");
   scanf(" %c", &choice);
   printf("\n");
 
@@ -52,9 +53,11 @@ void tempConverter(){
   printf(" Welcome to the Temperature Converter! ");
   printf("%.*s", 10, "-----------------");
   printf("\nChoose one from the list:\n");
-  printf("(1)Celcius to Fahrenheit\n(2)Celcius to Kelvin\n(3)Fahrenheit to Celcius\n(4)Fahrenheit to Kelvin\n(5)Kelvin to Celcius\n(6)Kelvin to Fahrenheit\n");
+  printf("(1)Celcius to Fahrenheit\t(2)Celcius to Kelvin\n");
+  printf("(3)Fahrenheit to Celcius\t(4)Fahrenheit to Kelvin\n");
+  printf("(5)Kelvin to Celcius\t\t(6)Kelvin to Fahrenheit\n");
   scanf(" %c", &choice);
-  printf("\nEnter a value: ");
+  printf("Enter a value: ");
   scanf("%f", &value);
 
   switch(choice){
@@ -82,11 +85,35 @@ void tempConverter(){
       result = (value * ((float) 9 / 5)) - 459.67;
       printf("%.2f°K is %.2f°F", value, result);
       break;
+    default:
+      printf("Oops...invalid option: '%c'", choice);
+      printf("\nTry again.");
   }
 }
 
 void currConverter(){
+  char choice;
+  float value;
+  float result;
 
+  printf("%.*s", 10, "-----------------");
+  printf(" Welcome to the Currency Converter! ");
+  printf("%.*s", 10, "-----------------");
+  printf("\nChoose one from the list:\n");
+  printf("(1)USD to PHP\t(2)USD to AUD\t(3)USD to JPY\n");
+  printf("(4)USD to EUR\t(5)USD to GBP\t(6)PHP to USD\n");
+  printf("(7)PHP to AUD\t(8)PHP to JPY\t(9)PHP to EUR\n");
+  printf("(10)PHP to GBP\t(11)AUD to USD\t(12)AUD to PHP\n");
+  printf("(13)AUD to JPY\t(14)AUD to EUR\t(15)AUD to GBP\n");
+  printf("(16)JPY to USD\t(17)JPY to PHP\t(18)JPY to AUD\n");
+  printf("(19)JPY to EUR\t(20)JPY to GBP\t(21)EUR to USD\n");
+  printf("(22)EUR to PHP\t(23)EUR to AUD\t(24)EUR to JPY\n");
+  printf("(25)EUR to EUR\t(26)EUR to GBP\t(27)GBP to USD\n");
+  printf("(28)GBP to PHP\t(29)GBP to AUD\t(30)GBP to JPY\n");
+  printf("(31)GBP to EUR\n");
+  scanf(" %c", &choice);
+  printf("Enter a value: ");
+  scanf("%f", &value);
 }
 
 void massConverter(){