Browse Source

added logic to ConKilometerToMiles

remotes/origin/feature
Enrico Schellenberger 11 months ago
parent
commit
104b8fa4d1
  1. 46
      src/main/c/ConvertMode.c

46
src/main/c/ConvertMode.c

@ -49,6 +49,18 @@ double getValue(int choice) {
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]);
break; 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() { 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() { double ConGram() {

Loading…
Cancel
Save