|
|
@ -10,11 +10,13 @@ |
|
|
|
int choice, startingUnit, endingUnit; |
|
|
|
double value, result; |
|
|
|
|
|
|
|
char Distance[] = { 'mm', 'cm', 'm', 'km' }; |
|
|
|
char Weight[] = { 'mg', 'g', 'kg', 't' }; |
|
|
|
char Fluid[] = { 'ml', 'l' }; |
|
|
|
char Distance[] = { 'mm', 'cm', 'm', 'km', 'feet/inch', 'miles'}; |
|
|
|
char Weight[] = { 'mg', 'g', 'kg', 't', 'pounds'}; |
|
|
|
char Fluid[] = { 'ml', 'l' , 'gallon'}; |
|
|
|
char Temp[] = { 'celsius', 'fahrenheit' }; |
|
|
|
char Speed[] = { 'km/h','mp/h' }; |
|
|
|
char Data[] = { 'B', 'KB', 'MB', 'GB', 'TB', 'PT' }; |
|
|
|
char Time[] = { 'ms', 's', 'min', 'h', 'd', 'w', 'mon', 'y' }; |
|
|
|
char Time[] = { 'ms', 's', 'min', 'h', 'd', 'w', 'mon', 'y'}; |
|
|
|
char currency[] = { 'E', 'D', 'R' }; |
|
|
|
|
|
|
|
|
|
|
@ -37,159 +39,183 @@ double getValue(int choice) { |
|
|
|
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
case 2: |
|
|
|
printf("\nEnter what the Unit is starting with (0 feet/Inch, 1 meter): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
double ConMeter(double meter, int startingUnit, int endingUnit) { |
|
|
|
switch (startingUnit) |
|
|
|
{ |
|
|
|
case 0: //mm to x |
|
|
|
switch (endingUnit) |
|
|
|
{ |
|
|
|
case 0: //1mm |
|
|
|
return meter; |
|
|
|
break; |
|
|
|
printf("\nEnter what the value should it be changed to (0 feet/Inch, 1 meter): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
case 1: //0.1cm |
|
|
|
return meter/10; |
|
|
|
break; |
|
|
|
result = ConMeterToFoot(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
case 2: //0.001m |
|
|
|
return meter/1000; |
|
|
|
break; |
|
|
|
if (endingUnit == 0) { //if feet/inch change to 4. in array of Distance |
|
|
|
endingUnit = 4; |
|
|
|
} |
|
|
|
|
|
|
|
case 3: //0.000001km |
|
|
|
return meter/1000000; |
|
|
|
break; |
|
|
|
else if (endingUnit == 1) { //if meter change to 2. in array of Distance |
|
|
|
endingUnit = 2; |
|
|
|
} |
|
|
|
|
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case 1: //cm to x |
|
|
|
switch (endingUnit) |
|
|
|
{ |
|
|
|
case 0: //10 |
|
|
|
return meter*10; |
|
|
|
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
case 1: //1 |
|
|
|
return meter; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
printf("\nEnter what the Unit is starting with (0 miles, 1 kilometer): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
case 2: //0.01 |
|
|
|
return meter/100; |
|
|
|
break; |
|
|
|
printf("\nEnter what the value should it be changed to (0 miles, 1 kilometer): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
case 3: //0.00001 |
|
|
|
return meter/100000; |
|
|
|
break; |
|
|
|
result = ConKilometerToMiles(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
if (endingUnit == 0) { //if miles change to 5. in array of Distance |
|
|
|
endingUnit = 5; |
|
|
|
} |
|
|
|
|
|
|
|
case 2: //m to x |
|
|
|
switch (endingUnit) |
|
|
|
{ |
|
|
|
case 0: //1000 |
|
|
|
return meter*1000; |
|
|
|
break; |
|
|
|
else if (endingUnit == 1) { //if kilometer change to 2. in array of Distance |
|
|
|
endingUnit = 3; |
|
|
|
} |
|
|
|
|
|
|
|
case 1: //100 |
|
|
|
return meter*100; |
|
|
|
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
case 2: //1 |
|
|
|
return meter; |
|
|
|
break; |
|
|
|
case 4://'mg', 'g', 'kg', 't' |
|
|
|
printf("\nEnter what the Unit is starting with (0 mg, 1 g, 2 kg , 3 t): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
case 3: //0.001 |
|
|
|
return meter/1000; |
|
|
|
break; |
|
|
|
printf("\nEnter what the value should it be changed to (0 mg, 1 g, 2 kg , 3 t): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
result = ConGram(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
case 3:// km to x |
|
|
|
switch (endingUnit) |
|
|
|
{ |
|
|
|
case 0: // 1000000 |
|
|
|
return meter*1000000; |
|
|
|
printf("\nThe convertet result is %dlf %d", result, Weight[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
case 1: // 100000 |
|
|
|
return meter*100000; |
|
|
|
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, Weight[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
case 2: // 1000 m |
|
|
|
return meter*1000; |
|
|
|
case 6://'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, Temp[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
case 3: //1 km |
|
|
|
return meter; |
|
|
|
case 7://'km/h','mp/h' |
|
|
|
printf("\nEnter what the Unit is starting with (0 km/h, 1 mp/h): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
printf("\nEnter what the value should it be changed to (0 km/h, 1 mp/h): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
result = ConSpeed(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
printf("\nThe convertet result is %dlf %d", result, Speed[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
case 8://'ml', 'l' |
|
|
|
printf("\nEnter what the Unit is starting with (0 ml, 1 l): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
printf("\nEnter what the value should it be changed to (0 ml, 1 l): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
result = ConLiter(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
printf("\nThe convertet result is %dlf %d", result, Fluid[endingUnit]); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
double ConMeterToFoot() { |
|
|
|
case 9://'ml', 'l' |
|
|
|
printf("\nEnter what the Unit is starting with (0 l, 1 gallon): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nEnter what the value should it be changed to (0 l, 1 gallon): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
double ConKilometerToMiles() { |
|
|
|
result = ConLiterToGallon(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nThe convertet result is %dlf %d", result, Fluid[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
double ConGram() { |
|
|
|
case 10://char Data[] = { 'B', 'KB', 'MB', 'GB', 'TB', 'PT' }; |
|
|
|
printf("\nEnter what the Unit is starting with (0 B, 1 KB, 2 MB , 3 GB, 4 TB, 5 PT): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nEnter what the value should it be changed to (0 B, 1 KB, 2 MB , 3 GB, 4 TB, 5 PT): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
double ConTemp() { |
|
|
|
result = ConData(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nThe convertet result is %dlf %d", result, Data[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
double ConSpeed() { |
|
|
|
case 11://char Distance[] = { 'mm', 'cm', 'm', 'km', 'feet/inch', 'miles'}; |
|
|
|
printf("\nEnter what the Unit is starting with (0 mm, 1 cm, 2 m , 3 km,): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nEnter what the value should it be changed to (0 mm, 1 cm, 2 m , 3 km,): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
double ConLiter() { |
|
|
|
result = ConArea(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nThe convertet result is %dlf %d²", result, Distance[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
double ConLiterToGallon() { |
|
|
|
case 12://char Distance[] = { 'mm', 'cm', 'm', 'km', 'feet/inch', 'miles'}; |
|
|
|
printf("\nEnter what the Unit is starting with (0 mm, 1 cm, 2 m , 3 km,): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nEnter what the value should it be changed to (0 mm, 1 cm, 2 m , 3 km,): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
double ConData() { |
|
|
|
result = ConArea(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nThe convertet result is %dlf %d³", result, Distance[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
double ConArea() { |
|
|
|
case 13://char Time[] = { 'ms', 's', 'min', 'h', 'd', 'w', 'mon', 'y' }; |
|
|
|
printf("\nEnter what the Unit is starting with (0 ms, 1 s, 2 min, 3 h, 4 d, 5 w, 6 mon, 7 y): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nEnter what the value should it be changed to (0 ms, 1 s, 2 min, 3 h, 4 d, 5 w, 6 mon, 7 y): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
double ConVolume() { |
|
|
|
result = ConTime(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|
|
|
break; |
|
|
|
|
|
|
|
double ConTime() { |
|
|
|
case 14: |
|
|
|
printf("\nEnter what the Unit is starting with (0 (24h), 1 (12h)): "); |
|
|
|
scanf("%d", &startingUnit); |
|
|
|
|
|
|
|
} |
|
|
|
printf("\nEnter what the value should it be changed to (0 (24h), 1 (12h)): "); |
|
|
|
scanf("%d", &endingUnit); |
|
|
|
|
|
|
|
double ConClock() { |
|
|
|
result = ConClock(value, startingUnit, endingUnit); |
|
|
|
|
|
|
|
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void unitConverterMode() { |
|
|
|
|
|
|
|
printf("Unit Converter Mode:\n"); |
|
|
@ -201,7 +227,7 @@ void unitConverterMode() { |
|
|
|
|
|
|
|
printf("Weight conversion:\n"); |
|
|
|
printf("4. Convert Gram (mg, g, kg)\n"); |
|
|
|
printf("5. Gram to Pounds \n") |
|
|
|
printf("5. Gram to Pounds \n"); |
|
|
|
|
|
|
|
printf("Temprature conversion:\n"); |
|
|
|
printf("6. Celsius to Fahrenheit\n"); |
|
|
@ -221,7 +247,7 @@ void unitConverterMode() { |
|
|
|
printf("12. Convert Volume (cm³, m³, km³)\n"); |
|
|
|
|
|
|
|
printf("Time conversion \n"); |
|
|
|
printf("13. Convert time (s, m, h) \n"); |
|
|
|
printf("13. Convert time (s, m, h, d, w, m, y) \n"); |
|
|
|
printf("14. Convert Clock (12 Hour, 24 Hour) \n"); |
|
|
|
|
|
|
|
printf("Time conversion \n"); |
|
|
|