diff --git a/5_Currency_Calculator/Currency_Calculator.c b/5_Currency_Calculator/Currency_Calculator.c index 24ab015..5cceb4f 100644 --- a/5_Currency_Calculator/Currency_Calculator.c +++ b/5_Currency_Calculator/Currency_Calculator.c @@ -1,4 +1,5 @@ #include +#include int main() { // variables @@ -13,6 +14,12 @@ int main() { printf("\n1 EUR\n2 USD\n3 JPY\n\nPlease type in the target currency: "); scanf("%i", &targetCurrency); + // check for valid input + if (currentCurrency < 1 || currentCurrency > 4 || targetCurrency < 1 || targetCurrency > 4) { + printf("Invalid currencies."); + return 1; + } + // calculating if (currentCurrency != targetCurrency) { // converting to base currency @@ -39,6 +46,9 @@ int main() { } } + // rounding fun + amount = round((amount*100))/100; + // output printf("Amount in target currency is: %lf", amount);