diff --git a/src/main/c/scientificMode.c b/src/main/c/scientificMode.c index a95495e..ddf2c7e 100644 --- a/src/main/c/scientificMode.c +++ b/src/main/c/scientificMode.c @@ -38,6 +38,40 @@ void executeLogarithmFunction(double num) { } 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(){ @@ -76,37 +110,7 @@ int scientificMode(){ break; 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; case 0: // Exit the loop