From 104b8fa4d17a3b4117ee099e25fe0874871926b4 Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Mon, 5 Feb 2024 19:04:30 +0100 Subject: [PATCH] added logic to ConKilometerToMiles --- src/main/c/ConvertMode.c | 48 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/main/c/ConvertMode.c b/src/main/c/ConvertMode.c index 874c333..e636254 100644 --- a/src/main/c/ConvertMode.c +++ b/src/main/c/ConvertMode.c @@ -49,6 +49,18 @@ double getValue(int choice) { printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); break; + case 3: + printf("\nEnter what the Unit is starting with (0 miles, 1 kilometer): "); + scanf("%d", &startingUnit); + + printf("\nEnter what the value should it be changed to (0 miles, 1 kilometer): "); + scanf("%d", &endingUnit); + + result = ConKilometerToMiles(value, startingUnit, endingUnit); + + printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); + break; + } } } @@ -192,7 +204,41 @@ double ConMeterToFoot(double distance, int startingUnit, int endingUnit) { } double ConKilometerToMiles() { - + switch (startingUnit) + { + case 0: //miles to x + switch (endingUnit) + { + case 0: //miles to miles + return distance; + break; + + case 1: //miles to kilometer + return distance * 1,60934; + break; + + default: + break; + } + + case 1: //kilometer to x + switch (endingUnit) + { + case 0: //kilometer to miles + return distance / 1, 60934; + break; + + case 1: //kilometer to kilometer + return distance; + break; + + default: + break; + } + + default: + break; + } } double ConGram() {