From fb678e3e845cac0414bff9d03fddbaa2e796e3b2 Mon Sep 17 00:00:00 2001 From: bochard Date: Sat, 19 Jul 2025 21:01:02 +0800 Subject: [PATCH] added list for currency converter --- main.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index e7975e4..6bedf0a 100644 --- 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(){ -- 2.39.5