diff --git a/src/main/c/scientificMode.c b/src/main/c/scientificMode.c index b855139..32a80c6 100644 --- a/src/main/c/scientificMode.c +++ b/src/main/c/scientificMode.c @@ -1,49 +1,71 @@ // scientificMode -#include -#include #include "taschenrechner.h" +#include +#include -int scientificMode(){ +int scientificMode() { - double num, result; + double num, result; - int choice; + int choice; - printf("Enter a number: "); - scanf("%lf", &num); // scan the number from user + 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("3: Logarithm\n"); - printf("4: Trigonometric\n"); - scanf("%d", &choice); // user choice + printf("Scientific mode Options:\n"); + printf("1: Square root\n"); + printf("2: Exponential\n"); + printf("3: Logarithm\n"); + printf("4: Trigonometric\n"); + scanf("%d", &choice); // user choice - switch(choice) { + switch (choice) { - case 1: // Square root - result = squareRootFunction(num); - break; + case 1: // Square root + result = squareRootFunction(num); + break; - case 2: // Exponential - result = exponentialFunction(num); - break; + case 2: // Exponential + result = exponentialFunction(num); + break; - case 3: // Logarithm - result = logarithmFunction(num); - break; + case 3: // Logarithm + result = logarithmFunction(num); + break; - case 4: // Trigonometric - result = sineFunction(num); - break; + case 4: // Trigonometric + printf("Trigonometric functions:\n"); + printf("5: Sine\n"); + printf("6: Cosine\n"); + printf("7: Tangent\n"); + int trigChoice; + scanf("%d", &trigChoice); - default: - printf("Invalid choice. Please try again.\n"); - return -1; // Return an error code to indicate failure + switch (trigChoice) { + case 5: // Sine + result = sin(num); + break; + case 6: // Cosine + result = cos(num); + break; + + case 7: // Tangent + result = tan(num); + break; + + default: + printf("Invalid trigonometric function choice.\n"); + return -1; // Return an error code to indicate failure } + break; + + default: + printf("Invalid choice. Please try again.\n"); + return -1; // Return an error code to indicate failure + } - printf("Result: %lf\n", result); - return result; + printf("Result: %lf\n", result); + return result; }