From 7c7e43a11f43f909d45ef5ccc394498d55d73a18 Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Wed, 31 Jan 2024 11:24:49 +0100 Subject: [PATCH 01/30] added minus function --- src/main/c/main_taschenrechner.c | 4 ++++ src/main/c/taschenrechner.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 79ece02..9727e18 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -10,3 +10,7 @@ int add(int a, int b) { return a+b; } + +int minus (int a, int b){ + return a - b; +} diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 1261fd7..0ebc004 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -3,4 +3,6 @@ int add(int a, int b); +int minus(int a, int b); + #endif // TASCHENRECHNER_H From 2088b143b6b6f4e2ac2e1b5fb9364a7781641521 Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Wed, 31 Jan 2024 11:33:20 +0100 Subject: [PATCH 02/30] added multiply function --- src/main/c/main_taschenrechner.c | 4 ++++ src/main/c/taschenrechner.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 9727e18..cec5d6f 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -14,3 +14,7 @@ int add(int a, int b) { int minus (int a, int b){ return a - b; } + +int multiply(int a, int b) { + return a * b; +} diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 0ebc004..e1ca752 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -5,4 +5,6 @@ int add(int a, int b); int minus(int a, int b); +int multiply(int a, int b); + #endif // TASCHENRECHNER_H From 0c9b2290c4a16a0c9f6e5c4453f3d3aa014ed3c7 Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Wed, 31 Jan 2024 11:39:42 +0100 Subject: [PATCH 03/30] added divide function --- src/main/c/main_taschenrechner.c | 6 ++++-- src/main/c/taschenrechner.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index cec5d6f..74668c7 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -6,9 +6,7 @@ int add(int a, int b) { - return a+b; - } int minus (int a, int b){ @@ -18,3 +16,7 @@ int minus (int a, int b){ int multiply(int a, int b) { return a * b; } + +int divide(int a, int b) { + return a / b; +} diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index e1ca752..3147d9d 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -7,4 +7,6 @@ int minus(int a, int b); int multiply(int a, int b); +int divide(int a, int b); + #endif // TASCHENRECHNER_H From 0649393e9383ad67e3e40fb5beaf8a7f1b9b84fd Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Thu, 1 Feb 2024 12:03:47 +0000 Subject: [PATCH 04/30] Added calculator modes functionality --- src/main/c/main_taschenrechner.c | 28 ++++++++++++++++++++++++++++ src/main/c/taschenrechner.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 74668c7..d4549dc 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -20,3 +20,31 @@ int multiply(int a, int b) { int divide(int a, int b) { return a / b; } + +int mode(int userChoice){ + + switch(userChoice) { + + case 1:return 1; // Basic mode + break; + + case 2:return 2; // Scientific mode (Trigonomertic functions, Logarithm and exponential functions.) + break; + + case 3:return 3; // Graph mode (Draw and visualize functions.) + break; + + case 4:return 4; // Programming mode (Binary , octal and hexadecimal ) + break; + + case 5:return 5; // Unit converter mode (length, weight volume etc.) + break; + + case 0: return 0; // printf("Exiting the calculator.\n"); + break; + + default: return -1; // printf("Invalid choice. Please try again.\n"); + + } + +} \ No newline at end of file diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 3147d9d..d410b22 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -9,4 +9,6 @@ int multiply(int a, int b); int divide(int a, int b); +int mode(int userChoice); + #endif // TASCHENRECHNER_H From c9c519066287ff1d73cf06f38d11087237b9c7d3 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Thu, 1 Feb 2024 12:26:57 +0000 Subject: [PATCH 05/30] Added display menu functionality --- src/main/c/main_taschenrechner.c | 18 +++++++++++++++++- src/main/c/taschenrechner.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index d4549dc..c64ab30 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -6,7 +6,7 @@ int add(int a, int b) { - return a+b; + return a + b; } int minus (int a, int b){ @@ -47,4 +47,20 @@ int mode(int userChoice){ } +} + + +// display the mode options: + +int displayMenu(){ + + printf("\nCalculator Modes: \n"); + printf("\n1: Basic Mode\n"); + printf("\n2: Scientific Mode (Trigonomertic functions, Logarithm and exponential functions.)\n"); + printf("\n3: Graph Mode (Draw and visualize functions.)\n"); + printf("\n4: Programming Mode (Binary , octal and hexadecimal )\n"); + printf("\n5: Unit converter Mode (length, weight volume etc.)\n"); + printf("\n0: Exit calculator\n"); + + return 1; // return 1 to check if the function works } \ No newline at end of file diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index d410b22..5bbfe6b 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -11,4 +11,6 @@ int divide(int a, int b); int mode(int userChoice); +int displayMenu(); + #endif // TASCHENRECHNER_H From 7a88cae1230b61928fe1601be2e74e2a2495cf28 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Thu, 1 Feb 2024 14:11:00 +0000 Subject: [PATCH 06/30] Added scientificMode function with user input (no functionality yet) --- src/main/c/main_taschenrechner.c | 46 ++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index c64ab30..526d9e9 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -1,6 +1,7 @@ #include -// #include +#include #include +#include #include "taschenrechner.h" @@ -21,6 +22,48 @@ int divide(int a, int b) { return a / b; } +// scientificmode + +int scientificmode(){ + + double num, result; + + int choice; + + printf("Enter a number: "); + + scanf("%lf", &num); // scan the number from user + + printf("Scientific mode Options:\n"); + printf("1: Square root:\n"); + printf("2: Exponential:\n"); + printf("2: Logarithm:\n"); + printf("4: Trigonomertic"); + scanf("%d", &choice); // user choice + + switch(choice) { + + case 1: // Square root + break; + + case 2: // Exponential + break; + + case 3: // Logarithm + break; + + case 4: // Trigonomertic + break; + + default: printf("Invalid choice. Please try again.\n"); + + } + + return result; +} + + +// change mode int mode(int userChoice){ switch(userChoice) { @@ -51,7 +94,6 @@ int mode(int userChoice){ // display the mode options: - int displayMenu(){ printf("\nCalculator Modes: \n"); From 97217b687c733aaa5de1cb297cb92b0b69c0f12a Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Thu, 1 Feb 2024 19:20:11 +0000 Subject: [PATCH 07/30] Added graph mode for testing with basic sin function table --- src/main/c/main_taschenrechner.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 526d9e9..7645288 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -22,9 +22,10 @@ int divide(int a, int b) { return a / b; } +// // scientificmode -int scientificmode(){ +int scientificMode(){ double num, result; @@ -62,6 +63,25 @@ int scientificmode(){ return result; } +// graphMode +void graphMode() { + double x, y; + + printf("Enter the range for x (start end step): "); + double x_start, x_end, x_step; + scanf("%lf %lf %lf", &x_start, &x_end, &x_step); + + printf("\nGraph for the function y = sin(x):\n"); + + printf(" x\t| y\n"); + printf("--------------\n"); + + for (x = x_start; x <= x_end; x += x_step) { + y = sin(x); + printf("%.2lf\t| %.2lf\n", x, y); + } +} + // change mode int mode(int userChoice){ From 550fe3158208681bb3dbc17f156b1f3ae206e45c Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Thu, 1 Feb 2024 21:07:36 +0000 Subject: [PATCH 08/30] Added programming mode without functionality --- src/main/c/main_taschenrechner.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 7645288..574ad40 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -82,6 +82,24 @@ void graphMode() { } } +// Programming mode + +void programmingMode() { + + int num1, num2, result; + char operator; + + printf("Enter first integer: "); + scanf("%d", &num1); + + printf("Enter operator (+, -, *, /): "); + scanf(" %c", &operator); + + printf("Enter second integer: "); + scanf("%d", &num2); + +} + // change mode int mode(int userChoice){ From 1b98800df7ab1fd922ebcc19409153e328bc7274 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Thu, 1 Feb 2024 21:15:38 +0000 Subject: [PATCH 09/30] Added Unit Converter mode without functionality --- src/main/c/main_taschenrechner.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 574ad40..60e57f1 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -22,7 +22,7 @@ int divide(int a, int b) { return a / b; } -// + // scientificmode int scientificMode(){ @@ -100,6 +100,23 @@ 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 8d69bf6c8ff17a3467b228cb6c6215dc95c7c345 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 15:18:30 +0000 Subject: [PATCH 10/30] Added sineFunction for trigonometric calculations --- src/main/c/main_taschenrechner.c | 6 ++++++ src/main/c/taschenrechner.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 60e57f1..f407180 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -22,6 +22,12 @@ int divide(int a, int b) { return a / b; } +// Trigonometric functions +double sineFunction(double angle) { + // Convert degrees to radians for trigonometric functions + return sin(angle * M_PI / 180.0); +} + // scientificmode diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 5bbfe6b..1ca10c6 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -9,6 +9,8 @@ int multiply(int a, int b); int divide(int a, int b); +double sineFunction(double angle); + int mode(int userChoice); int displayMenu(); From 5e548b90e558e2a3a232706fc7ee42cf4aa7e20f Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 15:21:46 +0000 Subject: [PATCH 11/30] Added cosine function for trigonometric calculations --- src/main/c/main_taschenrechner.c | 6 ++++++ src/main/c/taschenrechner.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index f407180..d99a933 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -29,6 +29,12 @@ double sineFunction(double angle) { } +double cosineFunction(double angle) { + // Convert degrees to radians for trigonometric functions + return cos(angle * M_PI / 180.0); +} + + // scientificmode int scientificMode(){ diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 1ca10c6..a5b9d40 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -11,6 +11,8 @@ int divide(int a, int b); double sineFunction(double angle); +double cosineFunction(double angle); + int mode(int userChoice); int displayMenu(); From 51fe20da4ff82dffd8784b79772fa0388c836efa Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 15:24:34 +0000 Subject: [PATCH 12/30] Added tangent function for trigonometric calculations --- src/main/c/main_taschenrechner.c | 4 ++++ src/main/c/taschenrechner.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index d99a933..20b7c33 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -34,6 +34,10 @@ double cosineFunction(double angle) { return cos(angle * M_PI / 180.0); } +double tangentFunction(double angle) { + // Convert degrees to radians for trigonometric functions + return tan(angle * M_PI / 180.0); +} // scientificmode diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index a5b9d40..a2b16d0 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -13,6 +13,8 @@ double sineFunction(double angle); double cosineFunction(double angle); +double tangentFunction(double angle); + int mode(int userChoice); int displayMenu(); From 0a09383b1eefad0baab83cb424b072538e95572e Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 15:27:26 +0000 Subject: [PATCH 13/30] Added logarithm function for base 10 logarithmic calculations --- src/main/c/main_taschenrechner.c | 9 ++++++++- src/main/c/taschenrechner.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 20b7c33..9158895 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -39,8 +39,15 @@ double tangentFunction(double angle) { return tan(angle * M_PI / 180.0); } -// scientificmode +// Logarithmic functions +double logarithmFunction(double x) { + // Logarithm with base 10 + return log10(x); +} + + +// scientificmode int scientificMode(){ double num, result; diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index a2b16d0..d177979 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -15,6 +15,8 @@ double cosineFunction(double angle); double tangentFunction(double angle); +double logarithmFunction(double x); + int mode(int userChoice); int displayMenu(); From 4e07ded997065a63883a9273cc4062011433136b Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 15:33:23 +0000 Subject: [PATCH 14/30] Added naturalLogarithmFunction (ln) for natural logarithmic calculations --- src/main/c/main_taschenrechner.c | 5 +++++ src/main/c/taschenrechner.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 9158895..eb9dad3 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -44,6 +44,11 @@ double logarithmFunction(double x) { // Logarithm with base 10 return log10(x); } + +double naturalLogarithmFunction(double x) { + // Natural logarithm (ln) + return log(x); +} diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index d177979..071fba0 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -9,14 +9,19 @@ int multiply(int a, int b); int divide(int a, int b); +// Trigonometric functions double sineFunction(double angle); double cosineFunction(double angle); double tangentFunction(double angle); +//.. +// Logarithmic functions double logarithmFunction(double x); +double naturalLogarithmFunction(double x); + int mode(int userChoice); int displayMenu(); From 03d5c29ff670d1179098b89ca93ad5a8a24ce5e3 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 15:40:57 +0000 Subject: [PATCH 15/30] Added logarithmBase2Function for base 2 logarithmic calculations --- src/main/c/main_taschenrechner.c | 6 +++++- src/main/c/taschenrechner.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index eb9dad3..6820e7f 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -39,6 +39,7 @@ double tangentFunction(double angle) { return tan(angle * M_PI / 180.0); } +//.. // Logarithmic functions double logarithmFunction(double x) { // Logarithm with base 10 @@ -49,8 +50,11 @@ double naturalLogarithmFunction(double x) { // Natural logarithm (ln) return log(x); } - +double logarithmBase2Function(double x) { + // Logarithm with base 2 + return log2(x); +} // scientificmode int scientificMode(){ diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 071fba0..1032900 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -22,6 +22,8 @@ double logarithmFunction(double x); double naturalLogarithmFunction(double x); +double logarithmBase2Function(double x); + int mode(int userChoice); int displayMenu(); From 440d7f5c25c789879bdf5517b1709a38a38dafca Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 15:43:33 +0000 Subject: [PATCH 16/30] Added exponentialFunction for exponential calculations --- src/main/c/main_taschenrechner.c | 7 +++++++ src/main/c/taschenrechner.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 6820e7f..fe59f96 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -55,6 +55,13 @@ double logarithmBase2Function(double x) { // Logarithm with base 2 return log2(x); } +//.. +// Exponential function +double exponentialFunction(double x) { + // Exponential function (e^x) + return exp(x); +} + // scientificmode int scientificMode(){ diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 1032900..17f2ce2 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -24,6 +24,10 @@ double naturalLogarithmFunction(double x); double logarithmBase2Function(double x); +//.. +// Exponential function +double exponentialFunction(double x); + int mode(int userChoice); int displayMenu(); From 08980879044d5fe5885dfab94b44a15eccfb4844 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 15:55:05 +0000 Subject: [PATCH 17/30] Added bitwiseAND function for bitwise AND operation --- src/main/c/main_taschenrechner.c | 5 +++++ src/main/c/taschenrechner.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index fe59f96..e365a95 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -62,6 +62,11 @@ double exponentialFunction(double x) { return exp(x); } +// .. +// Bitwise AND function +int bitwiseAND(int num1, int num2) { + return num1 & num2; +} // scientificmode int scientificMode(){ diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 17f2ce2..866141a 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -28,6 +28,10 @@ double logarithmBase2Function(double x); // Exponential function double exponentialFunction(double x); +// .. +// Bitwise AND function +int bitwiseAND(int num1, int num2); + int mode(int userChoice); int displayMenu(); From 0cc8033f3103513d6122cabfa6b245affcdfb5e6 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 15:56:53 +0000 Subject: [PATCH 18/30] Added bitwiseOR function for bitwise OR operation --- src/main/c/main_taschenrechner.c | 6 ++++++ src/main/c/taschenrechner.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index e365a95..e0bb699 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -68,6 +68,12 @@ int bitwiseAND(int num1, int num2) { return num1 & num2; } +// Bitwise OR function +int bitwiseOR(int num1, int num2) { + return num1 | num2; +} + + // scientificmode int scientificMode(){ diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 866141a..b3cc747 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -32,6 +32,9 @@ double exponentialFunction(double x); // Bitwise AND function int bitwiseAND(int num1, int num2); +// Bitwise OR function +int bitwiseOR(int num1, int num2); + int mode(int userChoice); int displayMenu(); From 8993cdde83dfcd3fa9b1afd0bafe9975583d03e3 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 15:59:18 +0000 Subject: [PATCH 19/30] Added bitwiseXOR function for bitwise XOR operation --- src/main/c/main_taschenrechner.c | 6 ++++++ src/main/c/taschenrechner.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index e0bb699..d9bda36 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -73,6 +73,12 @@ int bitwiseOR(int num1, int num2) { return num1 | num2; } +// Bitwise XOR function +int bitwiseXOR(int num1, int num2) { + return num1 ^ num2; +} + +//.. // scientificmode int scientificMode(){ diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index b3cc747..76acfb3 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -35,6 +35,9 @@ int bitwiseAND(int num1, int num2); // Bitwise OR function int bitwiseOR(int num1, int num2); +// Bitwise XOR function +int bitwiseXOR(int num1, int num2); + int mode(int userChoice); int displayMenu(); From 1a2e13f0c74a65bef60b88425037d4eff3cd7d1d Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Fri, 2 Feb 2024 16:03:53 +0000 Subject: [PATCH 20/30] Added squareRootFunction for calculating square roots --- src/main/c/main_taschenrechner.c | 7 +++++++ src/main/c/taschenrechner.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index d9bda36..af494d1 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -22,6 +22,13 @@ int divide(int a, int b) { return a / b; } +// Square root function +double squareRootFunction(double x) { + // Using the sqrt function from math.h + return sqrt(x); +} + +//.. // Trigonometric functions double sineFunction(double angle) { // Convert degrees to radians for trigonometric functions diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 76acfb3..1053da9 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -9,6 +9,10 @@ int multiply(int a, int b); int divide(int a, int b); +// Square root function +double squareRootFunction(double x); + +//.. // Trigonometric functions double sineFunction(double angle); From b35930f9c55928361b96e762a32ba94e67a1a855 Mon Sep 17 00:00:00 2001 From: lukazieg <2003lukas.zie@gmail.com> Date: Sat, 3 Feb 2024 11:24:06 +0100 Subject: [PATCH 21/30] added testForNumber.c --- src/main/c/testForNumber.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/c/testForNumber.c diff --git a/src/main/c/testForNumber.c b/src/main/c/testForNumber.c new file mode 100644 index 0000000..89784ed --- /dev/null +++ b/src/main/c/testForNumber.c @@ -0,0 +1,23 @@ +double testForNumber() { + double num; + char storage[25]; + char* notANumber; + + do { + //Emptys the standart output buffer to ensure that this function works in loops + //and returns the value of num after every loop + fflush(stdout); + + //fgets() reads the user input into the buffer storage (storage) + //the if condition is true as long as the input isn't empty + if (fgets(storage, sizeof storage, stdin) != NULL) { + //strtod() tries to convert the input into a double + //if there is anything but a number at any point of the array the pointer notANumber will point to this position + num = strtod(storage, ¬ANumber); + } + //isspace makes sure that notANumber doesn't point to an empty space + //the secount part makes sure that notANumber isn't pointing at 0 + } while (!isspace(*notANumber) && *notANumber != 0); + + return num; +} \ No newline at end of file From 944e3a15446f334563f26ff008fc9c9ccf3f4d61 Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Sat, 3 Feb 2024 11:56:50 +0100 Subject: [PATCH 22/30] unit tests added and adjusted calculations with double --- src/main/c/main_taschenrechner.c | 11 +++++++---- src/main/c/taschenrechner.h | 8 ++++---- src/test/c/test_taschenrechner.c | 27 +++++++++++++++++++++------ 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index af494d1..f1fccac 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -6,19 +6,22 @@ #include "taschenrechner.h" -int add(int a, int b) { +doulbe add(doulbe a, doulbe b) { return a + b; } -int minus (int a, int b){ +doulbe minus (doulbe a, doulbe b){ return a - b; } -int multiply(int a, int b) { +doulbe multiply(doulbe a, doulbe b) { return a * b; } -int divide(int a, int b) { +doulbe divide(doulbe a, doulbe b) { + if (b == 0) { + return 0; + } return a / b; } diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 1053da9..7b548f9 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -1,13 +1,13 @@ #ifndef TASCHENRECHNER_H #define TASCHENRECHNER_H -int add(int a, int b); +doulbe add(doulbe a, doulbe b); -int minus(int a, int b); +doulbe minus(doulbe a, doulbe b); -int multiply(int a, int b); +doulbe multiply(doulbe a, doulbe b); -int divide(int a, int b); +doulbe divide(doulbe a, doulbe b); // Square root function double squareRootFunction(double x); diff --git a/src/test/c/test_taschenrechner.c b/src/test/c/test_taschenrechner.c index d3fc8c9..6ad4cc7 100644 --- a/src/test/c/test_taschenrechner.c +++ b/src/test/c/test_taschenrechner.c @@ -14,14 +14,29 @@ void tearDown(void) void test_addition(void) { - /* arrange */ - char* result; - char expected[] = "2\n"; + doulbe result = add(1, 2); + TEST_ASSERT_EQUAL(3, result); +} + +void test_minus(void) +{ + doulbe result = minus(3, 1); + TEST_ASSERT_EQUAL(2, result); +} - /* act */ - result = convert(2); +void test_multiply(void) +{ + doulbe result = multiply(1, 2); + TEST_ASSERT_EQUAL(2, result); +} + +void test_divide(void) +{ + doulbe result = divide(4, 2); + TEST_ASSERT_EQUAL(2, result); - /* assert */ + doulbe result1 = divide(4, 0); + TEST_ASSERT_EQUAL(0, result1); } #endif // TEST From 8b6ad397fef77d124dcba0db124d4507963e4cae Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Sat, 3 Feb 2024 12:49:17 +0100 Subject: [PATCH 23/30] added new File BasicMode.c for Basic calculations --- src/main/c/BasicMode.c | 9 +++++++++ src/main/c/main_taschenrechner.c | 1 + 2 files changed, 10 insertions(+) create mode 100644 src/main/c/BasicMode.c diff --git a/src/main/c/BasicMode.c b/src/main/c/BasicMode.c new file mode 100644 index 0000000..30a7779 --- /dev/null +++ b/src/main/c/BasicMode.c @@ -0,0 +1,9 @@ +#include +#include +#include +#include + +#include "taschenrechner.h" +#include "main_taschenrechner.c" + + diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index f1fccac..dbe0447 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -4,6 +4,7 @@ #include #include "taschenrechner.h" +#include "BasicMode.c" doulbe add(doulbe a, doulbe b) { From bd2e1ef19fc64af699107016105b8c6e08e6b815 Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Sat, 3 Feb 2024 12:53:58 +0100 Subject: [PATCH 24/30] refractoring --- src/main/c/BasicMode.c | 1 - src/main/c/main_taschenrechner.c | 1 - src/main/c/taschenrechner.h | 7 +++++++ src/main/c/testForNumber.c | 7 +++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/c/BasicMode.c b/src/main/c/BasicMode.c index 30a7779..9904742 100644 --- a/src/main/c/BasicMode.c +++ b/src/main/c/BasicMode.c @@ -4,6 +4,5 @@ #include #include "taschenrechner.h" -#include "main_taschenrechner.c" diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index dbe0447..f1fccac 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -4,7 +4,6 @@ #include #include "taschenrechner.h" -#include "BasicMode.c" doulbe add(doulbe a, doulbe b) { diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 7b548f9..23cc26f 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -1,14 +1,21 @@ #ifndef TASCHENRECHNER_H #define TASCHENRECHNER_H +//add function doulbe add(doulbe a, doulbe b); +//minus function doulbe minus(doulbe a, doulbe b); +//multiply function doulbe multiply(doulbe a, doulbe b); +//divide function doulbe divide(doulbe a, doulbe b); +//get input and check if its a number +double testForNumber() + // Square root function double squareRootFunction(double x); diff --git a/src/main/c/testForNumber.c b/src/main/c/testForNumber.c index 89784ed..06438d1 100644 --- a/src/main/c/testForNumber.c +++ b/src/main/c/testForNumber.c @@ -1,3 +1,10 @@ +#include +#include +#include +#include + +#include "taschenrechner.h" + double testForNumber() { double num; char storage[25]; From a3cbfd7de1d0f83a90f0822b5abb162180971f1f Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Sat, 3 Feb 2024 16:59:42 +0100 Subject: [PATCH 25/30] added BasicMode.c and refractoring to testForOperator/taschenrechner.h --- src/main/c/BasicMode.c | 64 ++++++++++++++++--- src/main/c/taschenrechner.h | 115 ++++++++++++++++++----------------- src/main/c/testForOperator.c | 28 +++++++++ 3 files changed, 143 insertions(+), 64 deletions(-) create mode 100644 src/main/c/testForOperator.c diff --git a/src/main/c/BasicMode.c b/src/main/c/BasicMode.c index 9904742..396440f 100644 --- a/src/main/c/BasicMode.c +++ b/src/main/c/BasicMode.c @@ -1,8 +1,56 @@ -#include -#include -#include -#include - -#include "taschenrechner.h" - - +#include +#include +#include +#include + +#include "taschenrechner.h" + + +void BasicMode() { + char endtmp = '0'; //0 false, 1 true + double result = 0; + double numbers[100] = {0.0}; + char operatoren[100]; + + do { + //100 doubles in this array goes through the for loop till 100 numbers or = is entered + for (int i = 0; i < 100) { + printf("Enter a Number: "); + numbers[i] = testForNumber(); //gets number + + printf("Enter a operation: "); + operator[i] = testForOperator(); //gets operator + + if (i > 1) { //if function to prevent numbers[-1] + switch (operator[i]) //checks of the operator and switches to the case with the needed function + { + case '+': + result += add(numbers[i - 1], numbers[i]) + break; + + case '-': + result += minus(numbers[i - 1], numbers[i]) + break; + + case '*': + result += multiply(numbers[i - 1], numbers[i]) + break; + + case '/': + result += divide(numbers[i - 1], numbers[i]) + break; + + case '=': + printf("The result is: %d", result); + endtmp = 1; + break; + + default: + break; + } + } + i++; + } + } while (endtmp != '1') + +} diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 23cc26f..3855a6c 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -1,56 +1,59 @@ -#ifndef TASCHENRECHNER_H -#define TASCHENRECHNER_H - -//add function -doulbe add(doulbe a, doulbe b); - -//minus function -doulbe minus(doulbe a, doulbe b); - -//multiply function -doulbe multiply(doulbe a, doulbe b); - -//divide function -doulbe divide(doulbe a, doulbe b); - -//get input and check if its a number -double testForNumber() - -// Square root function -double squareRootFunction(double x); - -//.. -// Trigonometric functions -double sineFunction(double angle); - -double cosineFunction(double angle); - -double tangentFunction(double angle); - -//.. -// Logarithmic functions -double logarithmFunction(double x); - -double naturalLogarithmFunction(double x); - -double logarithmBase2Function(double x); - -//.. -// Exponential function -double exponentialFunction(double x); - -// .. -// Bitwise AND function -int bitwiseAND(int num1, int num2); - -// Bitwise OR function -int bitwiseOR(int num1, int num2); - -// Bitwise XOR function -int bitwiseXOR(int num1, int num2); - -int mode(int userChoice); - -int displayMenu(); - -#endif // TASCHENRECHNER_H +#ifndef TASCHENRECHNER_H +#define TASCHENRECHNER_H + +//add function +doulbe add(doulbe a, doulbe b); + +//minus function +doulbe minus(doulbe a, doulbe b); + +//multiply function +doulbe multiply(doulbe a, doulbe b); + +//divide function +doulbe divide(doulbe a, doulbe b); + +//get input and check if its a number +double testForNumber() + +//get input and check if its a operator +char testForOperator() + +// Square root function +double squareRootFunction(double x); + +//.. +// Trigonometric functions +double sineFunction(double angle); + +double cosineFunction(double angle); + +double tangentFunction(double angle); + +//.. +// Logarithmic functions +double logarithmFunction(double x); + +double naturalLogarithmFunction(double x); + +double logarithmBase2Function(double x); + +//.. +// Exponential function +double exponentialFunction(double x); + +// .. +// Bitwise AND function +int bitwiseAND(int num1, int num2); + +// Bitwise OR function +int bitwiseOR(int num1, int num2); + +// Bitwise XOR function +int bitwiseXOR(int num1, int num2); + +int mode(int userChoice); + +int displayMenu(); + +#endif // TASCHENRECHNER_H diff --git a/src/main/c/testForOperator.c b/src/main/c/testForOperator.c new file mode 100644 index 0000000..51b1931 --- /dev/null +++ b/src/main/c/testForOperator.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +#include "taschenrechner.h" + +char testForOperator() { + //saving the number of operators in a variable so it only needs to be changed in one location + int numberOfOperators = 5; + //array where all valid Operators are saved, can be esily expanded + char oppArray[numberOfOperators] = { '+','-','*','/','=' }; + char input; + bool validInput = false; + + //Loops as long as input isn't valid, enters at least one time + while (!validInput) { + scanf_s("%c\n", &input); + //checks every position of the array if a position is equal to input returns the input, which also stopps the function + for (int i = 0; i <= numberOfOperators; i++) { + if (input == oppArray[i]) { + return input; + } + } + //if the input was deemed invalid it asks for new input and goes to the top of the while loop + printf("Diese Eigabe war nicht zulässig probieren sie es noch einmal!\n"); + } +} \ No newline at end of file From 09e4f9d6b77c12f9925c0e7b049d83129d3a3d5f Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Sat, 3 Feb 2024 17:40:32 +0100 Subject: [PATCH 26/30] changed BasicMode.c to priorities operators --- src/main/c/BasicMode.c | 62 ++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/src/main/c/BasicMode.c b/src/main/c/BasicMode.c index 396440f..f68a11a 100644 --- a/src/main/c/BasicMode.c +++ b/src/main/c/BasicMode.c @@ -10,7 +10,7 @@ void BasicMode() { char endtmp = '0'; //0 false, 1 true double result = 0; double numbers[100] = {0.0}; - char operatoren[100]; + char operators[100]; do { //100 doubles in this array goes through the for loop till 100 numbers or = is entered @@ -19,38 +19,36 @@ void BasicMode() { numbers[i] = testForNumber(); //gets number printf("Enter a operation: "); - operator[i] = testForOperator(); //gets operator - - if (i > 1) { //if function to prevent numbers[-1] - switch (operator[i]) //checks of the operator and switches to the case with the needed function - { - case '+': - result += add(numbers[i - 1], numbers[i]) - break; - - case '-': - result += minus(numbers[i - 1], numbers[i]) - break; - - case '*': - result += multiply(numbers[i - 1], numbers[i]) - break; - - case '/': - result += divide(numbers[i - 1], numbers[i]) - break; - - case '=': - printf("The result is: %d", result); - endtmp = 1; - break; - - default: - break; - } - } - i++; + operators[i] = testForOperator(); //gets operator } } while (endtmp != '1') + + for (int i = 0; i < 100) {//checks all operators to check for priority + if ((operators[i] == '/' || operators[i] == '*') && i > 1) { //if operators[i] == / or * and i>1 so you dont get numbers[-1] + if (operators[i] == '/') { + result += divide(numbers[i - 1], numbers[i]); //divides if char is / and adds number to the result + } + // for all calculations we take the number and the number before that + else { // and do the operation + result += multiply(numbers[i - 1], numbers[i]); //multiplys if char is * and adds number to the result + } + } + + else if ((operators[i] == '+' || operators[i] == '-') && i > 1) { + if (operators[i] == '+') { + result += add(numbers[i - 1], numbers[i]); //adds if char is + and adds number to the result + } + + else { + result += minus(numbers[i - 1], numbers[i]); //subtrakts if char is - and adds number to the result + } + } + + else if (i<=1 && operator[i] == '=') { //if there are less then 2 numbers in the array + result = numbers[i]; //set result to the 0 digit + } + i++; + } + printf("The result is: %d", result); } From cc11e6eccd60ea42b1141f358abb9c643a1e6dfb Mon Sep 17 00:00:00 2001 From: Enrico Schellenberger Date: Sat, 3 Feb 2024 17:45:29 +0100 Subject: [PATCH 27/30] changed the last else if in BasicMode.c to include the = char --- src/main/c/BasicMode.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/c/BasicMode.c b/src/main/c/BasicMode.c index f68a11a..cfb5ded 100644 --- a/src/main/c/BasicMode.c +++ b/src/main/c/BasicMode.c @@ -48,7 +48,12 @@ void BasicMode() { else if (i<=1 && operator[i] == '=') { //if there are less then 2 numbers in the array result = numbers[i]; //set result to the 0 digit } + + else if (operator[i] == '=') { //if char is = + printf("The result is: %d", result); //print out the result + i = 100; + break; + } i++; } - printf("The result is: %d", result); } From cd40c3a9b40d0d5029383b23e995e2c65dd05a5e Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Sun, 4 Feb 2024 15:12:40 +0000 Subject: [PATCH 28/30] Updated Ceedling YAML for project structure --- project.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/project.yml b/project.yml index dac0d93..a360bc3 100644 --- a/project.yml +++ b/project.yml @@ -34,7 +34,7 @@ - +:src/test/c/** - -:src/test/c/support :source: - - src/main/c/** + - +:src/main/c/** :support: - src/test/c/support :libraries: [] @@ -98,4 +98,3 @@ :enabled: - stdout_pretty_tests_report - module_generator -... From ed3952a199900d04250bcc4a92dfbb1e7494335d Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Sun, 4 Feb 2024 18:45:48 +0000 Subject: [PATCH 29/30] Updated build script and Ceedling configuration --- create_folders.sh | 13 +++++++++++-- project.yml | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/create_folders.sh b/create_folders.sh index 3d96d3e..5d73167 100644 --- a/create_folders.sh +++ b/create_folders.sh @@ -1,2 +1,11 @@ -mkdir -p src/main/c -mkdir -p src/test/c/support +#!/bin/bash + +# Check if a Ceedling project exists +if [ -f "project.yml" ]; then + echo "Building and testing C project with Ceedling..." + ceedling test:all + exit $? +else + echo "No Ceedling project found in the current directory." + exit 1 +fi diff --git a/project.yml b/project.yml index a360bc3..4801bd7 100644 --- a/project.yml +++ b/project.yml @@ -88,9 +88,18 @@ :placement: :end :flag: "-l${1}" :path_flag: "-L ${1}" - :system: [] # for example, you might list 'm' to grab the math library - :test: [] - :release: [] + :system: + - m # Example: add 'm' to use the math library + :test: + - stdio + - string + - stdlib + - m # Example: add 'm' to use the math library in tests + :release: + - stdio + - string + - stdlib + - m # Example: add 'm' to use the math library in release builds :plugins: :load_paths: From b3773ad434c616376f18ba9d8d55e49c460483c0 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Sun, 4 Feb 2024 19:43:33 +0000 Subject: [PATCH 30/30] Fixed syntax errors in team member's code --- src/main/c/BasicMode.c | 12 ++++++------ src/main/c/main_taschenrechner.c | 8 ++++---- src/main/c/taschenrechner.h | 12 ++++++------ src/main/c/testForOperator.c | 5 +++-- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main/c/BasicMode.c b/src/main/c/BasicMode.c index cfb5ded..f6101c3 100644 --- a/src/main/c/BasicMode.c +++ b/src/main/c/BasicMode.c @@ -14,17 +14,17 @@ void BasicMode() { do { //100 doubles in this array goes through the for loop till 100 numbers or = is entered - for (int i = 0; i < 100) { + for (int i = 0; i < 100; i++) { printf("Enter a Number: "); numbers[i] = testForNumber(); //gets number printf("Enter a operation: "); operators[i] = testForOperator(); //gets operator } - } while (endtmp != '1') + } while (endtmp != '1'); - for (int i = 0; i < 100) {//checks all operators to check for priority + for (int i = 0; i < 100; i++) {//checks all operators to check for priority if ((operators[i] == '/' || operators[i] == '*') && i > 1) { //if operators[i] == / or * and i>1 so you dont get numbers[-1] if (operators[i] == '/') { result += divide(numbers[i - 1], numbers[i]); //divides if char is / and adds number to the result @@ -45,12 +45,12 @@ void BasicMode() { } } - else if (i<=1 && operator[i] == '=') { //if there are less then 2 numbers in the array + else if (i<=1 && operators[i] == '=') { //if there are less then 2 numbers in the array result = numbers[i]; //set result to the 0 digit } - else if (operator[i] == '=') { //if char is = - printf("The result is: %d", result); //print out the result + else if (operators[i] == '=') { //if char is = + printf("The result is: %f", result); //print out the result i = 100; break; } diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index f1fccac..02c981a 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -6,19 +6,19 @@ #include "taschenrechner.h" -doulbe add(doulbe a, doulbe b) { +double add(double a, double b) { return a + b; } -doulbe minus (doulbe a, doulbe b){ +double minus (double a, double b){ return a - b; } -doulbe multiply(doulbe a, doulbe b) { +double multiply(double a, double b) { return a * b; } -doulbe divide(doulbe a, doulbe b) { +double divide(double a, double b) { if (b == 0) { return 0; } diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 3855a6c..ffd85ad 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -2,22 +2,22 @@ #define TASCHENRECHNER_H //add function -doulbe add(doulbe a, doulbe b); +double add(double a, double b); //minus function -doulbe minus(doulbe a, doulbe b); +double minus(double a, double b); //multiply function -doulbe multiply(doulbe a, doulbe b); +double multiply(double a, double b); //divide function -doulbe divide(doulbe a, doulbe b); +double divide(double a, double b); //get input and check if its a number -double testForNumber() +double testForNumber(); //get input and check if its a operator -char testForOperator() +char testForOperator(); // Square root function double squareRootFunction(double x); diff --git a/src/main/c/testForOperator.c b/src/main/c/testForOperator.c index 51b1931..0ad34c6 100644 --- a/src/main/c/testForOperator.c +++ b/src/main/c/testForOperator.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "taschenrechner.h" @@ -9,7 +10,7 @@ char testForOperator() { //saving the number of operators in a variable so it only needs to be changed in one location int numberOfOperators = 5; //array where all valid Operators are saved, can be esily expanded - char oppArray[numberOfOperators] = { '+','-','*','/','=' }; + char oppArray[] = { '+','-','*','/','=' }; char input; bool validInput = false; @@ -23,6 +24,6 @@ char testForOperator() { } } //if the input was deemed invalid it asks for new input and goes to the top of the while loop - printf("Diese Eigabe war nicht zulässig probieren sie es noch einmal!\n"); + printf("The input was not allowed. Please try again!\n"); } } \ No newline at end of file