From b3773ad434c616376f18ba9d8d55e49c460483c0 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Sun, 4 Feb 2024 19:43:33 +0000 Subject: [PATCH] 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