From 8da7e42336863f0ef25ec18041502bf711ad1df2 Mon Sep 17 00:00:00 2001 From: Shivam Chaudhary Date: Thu, 9 Feb 2023 15:13:23 +0100 Subject: [PATCH] Add generalised function for currency exchange --- src/currencyExchange.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/currencyExchange.c b/src/currencyExchange.c index ccf75d3..b3dc39a 100644 --- a/src/currencyExchange.c +++ b/src/currencyExchange.c @@ -12,4 +12,14 @@ float toGBP(float euro) { float GBP = euro * CURRENT_GBP_RATE_OF_ONE_EURO; return GBP; +} + +float convert(float euro, int newCurrencyCode) { + switch(newCurrencyCode) { + case 1: + return ( euro * CURRENT_USD_RATE_OF_ONE_EURO ); + case 2: + return ( euro * CURRENT_GBP_RATE_OF_ONE_EURO ); + } + return -1; } \ No newline at end of file