Browse Source
Merge commit '4455b53c8908e9ff8246ea37820e2898470b5299' into develop
remotes/origin/kabrel
Merge commit '4455b53c8908e9ff8246ea37820e2898470b5299' into develop
remotes/origin/kabrel
fdai7782
11 months ago
3 changed files with 243 additions and 16 deletions
@ -0,0 +1,233 @@ |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <math.h> |
|||
#include <stdbool.h> |
|||
|
|||
#include "taschenrechner.h" |
|||
// Unit converter mode |
|||
|
|||
int choice, startingUnit, endingUnit; |
|||
double value, result; |
|||
|
|||
char Distance[] = { 'mm', 'cm', 'm', 'km' }; |
|||
char Weight[] = { 'mg', 'g', 'kg', 't' }; |
|||
char Fluid[] = { 'ml', 'l' }; |
|||
char Data[] = { 'B', 'KB', 'MB', 'GB', 'TB', 'PT' }; |
|||
char Time[] = { 'ms', 's', 'min', 'h', 'd', 'w', 'mon', 'y' }; |
|||
char currency[] = { 'E', 'D', 'R' }; |
|||
|
|||
|
|||
double getValue(int choice) { |
|||
printf("\nEnter the value to be converted: "); |
|||
scanf("%lf", &value); |
|||
|
|||
while (choice < 0 && choice >= 15) { |
|||
switch (choice) |
|||
{ |
|||
case 1: |
|||
printf("\nEnter what the Unit is starting with (0 mm, 1 cm, 2 m, 3 km): "); |
|||
scanf("%d", &startingUnit); |
|||
//1 10 1.000 1.000.000 |
|||
printf("\nEnter what the value should it be changed to (0 mm, 1 cm, 2 m, 3 km): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConMeter(value, startingUnit,endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|||
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 ConKilometerToMiles() { |
|||
|
|||
} |
|||
|
|||
double ConGram() { |
|||
|
|||
} |
|||
|
|||
double ConTemp() { |
|||
|
|||
} |
|||
|
|||
double ConSpeed() { |
|||
|
|||
} |
|||
|
|||
double ConLiter() { |
|||
|
|||
} |
|||
|
|||
double ConLiterToGallon() { |
|||
|
|||
} |
|||
|
|||
double ConData() { |
|||
|
|||
} |
|||
|
|||
double ConArea() { |
|||
|
|||
} |
|||
|
|||
double ConVolume() { |
|||
|
|||
} |
|||
|
|||
double ConTime() { |
|||
|
|||
} |
|||
|
|||
double ConClock() { |
|||
|
|||
} |
|||
|
|||
|
|||
void unitConverterMode() { |
|||
|
|||
printf("Unit Converter Mode:\n"); |
|||
|
|||
printf("Distance conversions:\n"); |
|||
printf("1. Convert Meter (cm, m, km)\n"); |
|||
printf("2. Meter to foot/inches\n"); |
|||
printf("3. Kilometer to Miles\n"); |
|||
|
|||
printf("Weight conversion:\n"); |
|||
printf("4. Convert Gram (mg, g, kg)\n"); |
|||
printf("5. Gram to Pounds \n") |
|||
|
|||
printf("Temprature conversion:\n"); |
|||
printf("6. Celsius to Fahrenheit\n"); |
|||
|
|||
printf("Speed conversion:\n"); |
|||
printf("7. km/h to mph \n"); |
|||
|
|||
printf("Fluid conversion:\n"); |
|||
printf("8. Convert Liter (ml, l, kl) \n"); |
|||
printf("9. Liter to Gallon\n"); |
|||
|
|||
printf("Data conversions:\n"); |
|||
printf("10. Convert Data size (MB, GB, TB)\n"); |
|||
|
|||
printf("Area/Volume conversions \n"); |
|||
printf("11. Convert area (cm², m², km²) \n"); |
|||
printf("12. Convert Volume (cm³, m³, km³)\n"); |
|||
|
|||
printf("Time conversion \n"); |
|||
printf("13. Convert time (s, m, h) \n"); |
|||
printf("14. Convert Clock (12 Hour, 24 Hour) \n"); |
|||
|
|||
printf("Time conversion \n"); |
|||
printf("15. Convert currency (Euro, Dollar, Russian Rubel) \n"); |
|||
|
|||
printf("\nEnter your choice (Exit with 0): "); |
|||
scanf("%d", &choice); |
|||
getValue(choice); |
|||
} |
@ -0,0 +1,10 @@ |
|||
// scientific.c |
|||
#include <stdio.h> |
|||
#include <math.h> |
|||
#include "taschenrechner.h" |
|||
|
|||
|
|||
double scientificMode() { |
|||
|
|||
return 0.0; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue