|
@ -115,364 +115,11 @@ 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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double ConMeter(double meter, int startingUnit, int endingUnit) { |
|
|
|
|
|
switch (startingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //mm to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //1mm |
|
|
|
|
|
return meter; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: //0.1cm |
|
|
|
|
|
return meter/10; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: //0.001m |
|
|
|
|
|
return meter/1000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 3: //0.000001km |
|
|
|
|
|
return meter/1000000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 1: //cm to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //10 |
|
|
|
|
|
return meter*10; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: //1 |
|
|
|
|
|
return meter; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: //0.01 |
|
|
|
|
|
return meter/100; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 3: //0.00001 |
|
|
|
|
|
return meter/100000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 2: //m to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //1000 |
|
|
|
|
|
return meter*1000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: //100 |
|
|
|
|
|
return meter*100; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: //1 |
|
|
|
|
|
return meter; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 3: //0.001 |
|
|
|
|
|
return meter/1000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 3:// km to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: // 1000000 |
|
|
|
|
|
return meter*1000000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: // 100000 |
|
|
|
|
|
return meter*100000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: // 1000 m |
|
|
|
|
|
return meter*1000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 3: //1 km |
|
|
|
|
|
return meter; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
double ConMeterToFoot(double distance, int startingUnit, int endingUnit) { |
|
|
|
|
|
switch (startingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //feet/inch to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //feet/inch to feet/inch |
|
|
|
|
|
return distance; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: //feet/inch to meter |
|
|
|
|
|
return distance / 3,28084; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 1: //meter to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //meter to feet/inch |
|
|
|
|
|
return distance * 3, 28084; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: //feet/inch to feet/inch |
|
|
|
|
|
return distance; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double ConKilometerToMiles(double distance, int startingUnit, int endingUnit) { |
|
|
|
|
|
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 weight, int startingUnit, int endingUnit) { |
|
|
|
|
|
switch (startingUnit) |
|
|
|
|
|
{//'mg', 'g', 'kg', 't' |
|
|
|
|
|
case 0: //mg to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //1 |
|
|
|
|
|
return weight; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: //0.001 |
|
|
|
|
|
return weight / 1000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: //0.000001 |
|
|
|
|
|
return weight / 1000000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 3: //0.000000001 |
|
|
|
|
|
return weight / 1000000000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 1: //g to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //1000 |
|
|
|
|
|
return weight * 1000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: //1 |
|
|
|
|
|
return weight; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: //0.01 |
|
|
|
|
|
return weight / 100; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 3: //0.000001 |
|
|
|
|
|
return weight / 100000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 2: //kg to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //1000 |
|
|
|
|
|
return weight * 1000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: //100 |
|
|
|
|
|
return weight * 100; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: //1 |
|
|
|
|
|
return weight; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 3: //0.001 |
|
|
|
|
|
return weight / 1000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 3://t to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: // 1000000000 |
|
|
|
|
|
return weight * 1000000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: // 1000000 |
|
|
|
|
|
return weight * 100000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: // 1000 |
|
|
|
|
|
return weight * 1000; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 3: //1 |
|
|
|
|
|
return weight; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double ConGramToPounds(double weight, int startingUnit, int endingUnit) { |
|
|
|
|
|
switch (startingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //kg to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //kg to pounds |
|
|
|
|
|
return weight *= 2.20462; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: //kg to kg |
|
|
|
|
|
return weight; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 1: //pounds to x |
|
|
|
|
|
switch (endingUnit) |
|
|
|
|
|
{ |
|
|
|
|
|
case 0: //pounds to kg |
|
|
|
|
|
return weight *= 0,453592; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 1: //pounds to pounds |
|
|
|
|
|
return weight; |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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() { |
|
|
double ConSpeed() { |
|
|
|
|
|
|
|
|