diff --git a/src/main/c/ConvertMode.c b/src/main/c/ConvertMode.c index f18e08f..f50e6e6 100644 --- a/src/main/c/ConvertMode.c +++ b/src/main/c/ConvertMode.c @@ -13,6 +13,7 @@ double value, result; char Distance[] = { 'mm', 'cm', 'm', 'km', 'feet/inch', 'miles'}; char Weight[] = { 'mg', 'g', 'kg', 't' }; char Fluid[] = { 'ml', 'l' }; +char Temp[] = {'celsius', 'fahrenheit'} char Data[] = { 'B', 'KB', 'MB', 'GB', 'TB', 'PT' }; char Time[] = { 'ms', 's', 'min', 'h', 'd', 'w', 'mon', 'y' }; char currency[] = { 'E', 'D', 'R' }; @@ -90,6 +91,18 @@ double getValue(int choice) { printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); break; + case 5://'celsius', 'fahrenheit' + printf("\nEnter what the Unit is starting with (0 celsius, 1 fahrenheit): "); + scanf("%d", &startingUnit); + + printf("\nEnter what the value should it be changed to (0 celsius, 1 fahrenheit): "); + scanf("%d", &endingUnit); + + result = ConTemp(value, startingUnit, endingUnit); + + printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); + break; + } } @@ -371,8 +384,42 @@ double ConGram(double weight, int startingUnit, int endingUnit) { } } -double ConTemp() { - +double ConTemp(double Temp, int startingUnit, int endingUnit) { + switch (startingUnit) + { + case 0: //celsius to x + switch (endingUnit) + { + case 0: //celsius to fahrenheit + return Temp = (Temp - 32) * 0, 55555555; + break; + + case 1: //celsius to celsius + return Temp; + break; + + default: + break; + } + + case 1: //fahrenheit to x + switch (endingUnit) + { + case 0: //fahrenheit to celsius + return Temp = (Temp * 1,8) + 32; + break; + + case 1: //fahrenheit to fahrenheit + return Temp; + break; + + default: + break; + } + + default: + break; + } } double ConSpeed() {