Browse Source

refactoring: Extracted the logarithm function from the scientificMode and moved in the executeScientificFunction

remotes/origin/kabrel
fdai7782 11 months ago
parent
commit
de04361737
  1. 67
      src/main/c/scientificMode.c

67
src/main/c/scientificMode.c

@ -4,6 +4,41 @@
#include <math.h>
#include "taschenrechner.h"
// Logarithm
void executeLogarithmFunction(double num) {
int logChoice;
do {
printf("Logarithm Options:\n");
printf("1: Logarithm (base 10)\n");
printf("2: Natural Logarithm (ln)\n");
printf("3: Logarithm (base 2)\n");
printf("0: Exit Logarithm Menu\n");
scanf("%d", &logChoice);
switch (logChoice) {
case 1: // Logarithm (base 10)
printf("Result: %lf\n", logarithmFunction(num));
break;
case 2: // Natural Logarithm (ln)
printf("Result: %lf\n", naturalLogarithmFunction(num));
break;
case 3: // Logarithm (base 2)
printf("Result: %lf\n", logarithmBase2Function(num));
break;
case 0: // Exit the logarithm menu
break;
default:
printf("Invalid logarithm function choice. Please try again.\n");
}
} while (logChoice != 0);
}
int scientificMode(){
double num, result;
@ -37,37 +72,7 @@ int scientificMode(){
break;
case 3: // Logarithm
do {
printf("Logarithm Options:\n");
printf("1: Logarithm (base 10)\n");
printf("2: Natural Logarithm (ln)\n");
printf("3: Logarithm (base 2)\n");
printf("0: Exit Logarithm Menu\n");
scanf("%d", &logChoice);
switch(logChoice) {
case 1: // Logarithm (base 10)
result = logarithmFunction(num);
printf("Result: %lf\n", result);
break;
case 2: // Natural Logarithm (ln)
result = naturalLogarithmFunction(num);
printf("Result: %lf\n", result);
break;
case 3: // Logarithm (base 2)
result = logarithmBase2Function(num);
printf("Result: %lf\n", result);
break;
case 0: // Exit the logarithm menu
break;
default:
printf("Invalid logarithm function choice. Please try again.\n");
}
} while (logChoice != 0);
executeLogarithmFunction(num);
break;
case 4: // Trigonometric

Loading…
Cancel
Save