Browse Source

refactoring: Extracted the trigonometric function from the scientificMode and moved in the executeTrigonometricFunction

remotes/origin/kabrel
fdai7782 11 months ago
parent
commit
54d7fbb0f6
  1. 66
      src/main/c/scientificMode.c

66
src/main/c/scientificMode.c

@ -38,6 +38,40 @@ void executeLogarithmFunction(double num) {
} while (logChoice != 0); } while (logChoice != 0);
} }
// Trigonometric
void executeTrigonometricFunction(double num) {
int trigChoice;
do {
printf("Trigonometric functions:\n");
printf("1: Sine\n");
printf("2: Cosine\n");
printf("3: Tangent\n");
printf("0: Exit Trigonometric Menu\n");
scanf("%d", &trigChoice);
switch (trigChoice) {
case 1: // Sine
printf("Result: %lf\n", sineFunction(num));
break;
case 2: // Cosine
printf("Result: %lf\n", cosineFunction(num));
break;
case 3: // Tangent
printf("Result: %lf\n", tangentFunction(num));
break;
case 0: // Exit the trigonometric menu
break;
default:
printf("Invalid trigonometric function choice. Please try again.\n");
}
} while (trigChoice != 0);
}
int scientificMode(){ int scientificMode(){
@ -76,37 +110,7 @@ int scientificMode(){
break; break;
case 4: // Trigonometric case 4: // Trigonometric
do {
printf("Trigonometric functions:\n");
printf("1: Sine\n");
printf("2: Cosine\n");
printf("3: Tangent\n");
printf("0: Exit Trigonometric Menu\n");
scanf("%d", &trigChoice);
switch(trigChoice) {
case 1: // Sine
result = sineFunction(num);
printf("Result: %lf\n", result);
break;
case 2: // Cosine
result = cosineFunction(num);
printf("Result: %lf\n", result);
break;
case 3: // Tangent
result = tangentFunction(num);
printf("Result: %lf\n", result);
break;
case 0: // Exit the trigonometric menu
break;
default:
printf("Invalid trigonometric function choice. Please try again.\n");
}
} while (trigChoice != 0);
executeTrigonometricFunction(num);
break; break;
case 0: // Exit the loop case 0: // Exit the loop

Loading…
Cancel
Save