From e1ed311b32e5d7b66cd57e99f3c44c2584ad3d4a Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Mon, 5 Feb 2024 12:10:27 +0100 Subject: [PATCH 1/6] added ConvertMode.c with all conversion options --- src/main/c/ConvertMode.c | 51 ++++++++++++++++++++++++++++++++ src/main/c/main_taschenrechner.c | 16 ---------- 2 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 src/main/c/ConvertMode.c diff --git a/src/main/c/ConvertMode.c b/src/main/c/ConvertMode.c new file mode 100644 index 0000000..ef9e7be --- /dev/null +++ b/src/main/c/ConvertMode.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include +#include + +#include "taschenrechner.h" +// Unit converter mode + +void unitConverterMode() { + int choice; + double value, result; + + 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("Temprature conversion:\n"); + printf("5. Celsius to Fahrenheit\n"); + + printf("Speed conversion:\n"); + printf("6. km/h to mph \n"); + + printf("Fluid conversion:\n"); + printf("7. Convert Liter (ml, l, kl) \n"); + printf("8. Liter to Gallon\n"); + + printf("Data conversions:\n"); + printf("9. Convert Data size (MB, GB, TB)\n"); + + printf("Area/Volume conversions \n"); + printf("10. Convert area (cm², m², km²) \n"); + printf("11. 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("\nEnter your choice (Exit with 0): "); + scanf("%d", &choice); + + printf("Enter the value to convert: "); + scanf("%lf", &value); + +} \ No newline at end of file diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 02c981a..edbc325 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -166,23 +166,7 @@ void programmingMode() { } -// Unit converter mode -void unitConverterMode() { - int choice; - double value, result; - - printf("Unit Converter Mode:\n"); - printf("1. Meter to Kilometer\n"); - printf("2. Kilogram to Gram\n"); - printf("3. Celsius to Fahrenheit\n"); - printf("Enter your choice: "); - scanf("%d", &choice); - - printf("Enter the value to convert: "); - scanf("%lf", &value); - -} // change mode int mode(int userChoice){ From 43b098aec46c7228023c4a45a3e4b2ada1e927c1 Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Mon, 5 Feb 2024 12:28:43 +0100 Subject: [PATCH 2/6] added Con Functions and query to ConvertMode.c --- src/main/c/ConvertMode.c | 74 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/src/main/c/ConvertMode.c b/src/main/c/ConvertMode.c index ef9e7be..e9ec6ef 100644 --- a/src/main/c/ConvertMode.c +++ b/src/main/c/ConvertMode.c @@ -7,6 +7,77 @@ #include "taschenrechner.h" // Unit converter mode +double getValue() { + printf("Enter the first value to convert: "); + scanf("%lf", &value); + + printf("Enter the second value to convert: "); + scanf("%lf", &value); + + while (choice < 0 && choice >= 14) { + switch (choice) + { + case 1: + + break; + + } + } +} + +double ConMeter() { + +} + +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() { int choice; double value, result; @@ -45,7 +116,6 @@ void unitConverterMode() { printf("\nEnter your choice (Exit with 0): "); scanf("%d", &choice); - printf("Enter the value to convert: "); - scanf("%lf", &value); + } \ No newline at end of file From 2424f9219111660ac1ba70168c308f0ac23a2a7e Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Mon, 5 Feb 2024 14:01:13 +0100 Subject: [PATCH 3/6] added Unit arrays and switch case for Meter conversionto ConvertMode.c --- src/main/c/ConvertMode.c | 52 +++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/src/main/c/ConvertMode.c b/src/main/c/ConvertMode.c index e9ec6ef..454577f 100644 --- a/src/main/c/ConvertMode.c +++ b/src/main/c/ConvertMode.c @@ -7,25 +7,39 @@ #include "taschenrechner.h" // Unit converter mode -double getValue() { - printf("Enter the first value to convert: "); +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); - printf("Enter the second value to convert: "); - scanf("%lf", &value); - - while (choice < 0 && choice >= 14) { + while (choice < 0 && choice >= 15) { switch (choice) { case 1: + printf("\nEnter what the Unit is starting with: "); + scanf("%d", &startingUnit); + + printf("\nEnter what the value should it be changed to: "); + scanf("%d", &endingUnit); + result = ConMeter(value, startingUnit,endingUnit); + + printf("\nThe convertet result is %dlf %d", result, Distance[unit]); break; } } } -double ConMeter() { +double ConMeter(double meter, int startingUnit, int endingUnit) { } @@ -79,8 +93,6 @@ double ConClock() { void unitConverterMode() { - int choice; - double value, result; printf("Unit Converter Mode:\n"); @@ -91,31 +103,33 @@ void unitConverterMode() { printf("Weight conversion:\n"); printf("4. Convert Gram (mg, g, kg)\n"); + printf("5. Gram to Pounds \n") printf("Temprature conversion:\n"); - printf("5. Celsius to Fahrenheit\n"); + printf("6. Celsius to Fahrenheit\n"); printf("Speed conversion:\n"); - printf("6. km/h to mph \n"); + printf("7. km/h to mph \n"); printf("Fluid conversion:\n"); - printf("7. Convert Liter (ml, l, kl) \n"); - printf("8. Liter to Gallon\n"); + printf("8. Convert Liter (ml, l, kl) \n"); + printf("9. Liter to Gallon\n"); printf("Data conversions:\n"); - printf("9. Convert Data size (MB, GB, TB)\n"); + printf("10. Convert Data size (MB, GB, TB)\n"); printf("Area/Volume conversions \n"); - printf("10. Convert area (cm², m², km²) \n"); - printf("11. Convert Volume (cm³, m³, km³)\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); } \ No newline at end of file From 90482fe0a12aab29e2ca1c4af56572b3225fccfb Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Mon, 5 Feb 2024 16:37:20 +0000 Subject: [PATCH 4/6] Renamed the sh file to build-project --- create_folders.sh => build-project.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename create_folders.sh => build-project.sh (100%) diff --git a/create_folders.sh b/build-project.sh similarity index 100% rename from create_folders.sh rename to build-project.sh From 002a3cca8078c044d265918db2199b335c01daa6 Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Mon, 5 Feb 2024 17:51:48 +0100 Subject: [PATCH 5/6] added ConMeter logic to ConvertMode.c --- src/main/c/ConvertMode.c | 110 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 104 insertions(+), 6 deletions(-) diff --git a/src/main/c/ConvertMode.c b/src/main/c/ConvertMode.c index 454577f..2d9e9ae 100644 --- a/src/main/c/ConvertMode.c +++ b/src/main/c/ConvertMode.c @@ -9,6 +9,7 @@ int choice, startingUnit, endingUnit; double value, result; + char Distance[] = { 'mm', 'cm', 'm', 'km' }; char Weight[] = { 'mg', 'g', 'kg', 't' }; char Fluid[] = { 'ml', 'l' }; @@ -16,6 +17,7 @@ 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); @@ -24,15 +26,15 @@ double getValue(int choice) { switch (choice) { case 1: - printf("\nEnter what the Unit is starting with: "); + 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: "); + //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[unit]); + printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); break; } @@ -40,11 +42,107 @@ double getValue(int choice) { } 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() { From 4455b53c8908e9ff8246ea37820e2898470b5299 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Mon, 5 Feb 2024 17:13:54 +0000 Subject: [PATCH 6/6] Added scientific.c file --- src/main/c/scientific.c | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/c/scientific.c diff --git a/src/main/c/scientific.c b/src/main/c/scientific.c new file mode 100644 index 0000000..0500106 --- /dev/null +++ b/src/main/c/scientific.c @@ -0,0 +1,10 @@ +// scientific.c +#include +#include +#include "taschenrechner.h" + + +double scientificMode() { + + return 0.0; +}