|
@ -11,7 +11,7 @@ int choice, startingUnit, endingUnit; |
|
|
double value, result; |
|
|
double value, result; |
|
|
|
|
|
|
|
|
char Distance[] = { 'mm', 'cm', 'm', 'km', 'feet/inch', 'miles'}; |
|
|
char Distance[] = { 'mm', 'cm', 'm', 'km', 'feet/inch', 'miles'}; |
|
|
char Weight[] = { 'mg', 'g', 'kg', 't' }; |
|
|
|
|
|
|
|
|
char Weight[] = { 'mg', 'g', 'kg', 't', 'pounds'}; |
|
|
char Fluid[] = { 'ml', 'l' }; |
|
|
char Fluid[] = { 'ml', 'l' }; |
|
|
char Temp[] = {'celsius', 'fahrenheit'} |
|
|
char Temp[] = {'celsius', 'fahrenheit'} |
|
|
char Data[] = { 'B', 'KB', 'MB', 'GB', 'TB', 'PT' }; |
|
|
char Data[] = { 'B', 'KB', 'MB', 'GB', 'TB', 'PT' }; |
|
@ -91,7 +91,19 @@ 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 5://'celsius', 'fahrenheit' |
|
|
|
|
|
|
|
|
case 5://'kg', 'pounds' |
|
|
|
|
|
printf("\nEnter what the Unit is starting with (0 kg, 1 pounds): "); |
|
|
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
|
|
|
|
printf("\nEnter what the value should it be changed to (0 kg, 1 pounds): "); |
|
|
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
|
|
|
|
result = ConGramToPounds(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
|
|
|
|
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 6://'celsius', 'fahrenheit' |
|
|
printf("\nEnter what the Unit is starting with (0 celsius, 1 fahrenheit): "); |
|
|
printf("\nEnter what the Unit is starting with (0 celsius, 1 fahrenheit): "); |
|
|
scanf("%d", &startingUnit); |
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
@ -103,6 +115,8 @@ 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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -384,18 +398,56 @@ double ConGram(double weight, int startingUnit, int endingUnit) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
double ConTemp(double Temp, int startingUnit, int endingUnit) { |
|
|
|
|
|
|
|
|
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) |
|
|
switch (startingUnit) |
|
|
{ |
|
|
{ |
|
|
case 0: //celsius to x |
|
|
case 0: //celsius to x |
|
|
switch (endingUnit) |
|
|
switch (endingUnit) |
|
|
{ |
|
|
{ |
|
|
case 0: //celsius to fahrenheit |
|
|
case 0: //celsius to fahrenheit |
|
|
return Temp = (Temp - 32) * 0, 55555555; |
|
|
|
|
|
|
|
|
return temp = (temp - 32) * 0, 55555555; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 1: //celsius to celsius |
|
|
case 1: //celsius to celsius |
|
|
return Temp; |
|
|
|
|
|
|
|
|
return temp; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
@ -406,11 +458,11 @@ double ConTemp(double Temp, int startingUnit, int endingUnit) { |
|
|
switch (endingUnit) |
|
|
switch (endingUnit) |
|
|
{ |
|
|
{ |
|
|
case 0: //fahrenheit to celsius |
|
|
case 0: //fahrenheit to celsius |
|
|
return Temp = (Temp * 1,8) + 32; |
|
|
|
|
|
|
|
|
return temp = (temp * 1,8) + 32; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case 1: //fahrenheit to fahrenheit |
|
|
case 1: //fahrenheit to fahrenheit |
|
|
return Temp; |
|
|
|
|
|
|
|
|
return temp; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
|