From 98e8d6af3dcf0fd980a721f34e11a6dcea1ca01f Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Tue, 6 Feb 2024 17:24:25 +0000 Subject: [PATCH] refactoring: Extracted the trigonometric options from the executeTrigonometricFunction and move them into getTrigonometricChoice --- src/main/c/scientificMode.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/c/scientificMode.c b/src/main/c/scientificMode.c index 0a7d37a..3e025f8 100644 --- a/src/main/c/scientificMode.c +++ b/src/main/c/scientificMode.c @@ -16,6 +16,17 @@ int getLogarithmChoice() { return logChoice; } +int getTrigonometricChoice() { + int trigChoice; + 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); + return trigChoice; +} + // Logarithm void executeLogarithmFunction(double num) { @@ -52,12 +63,8 @@ 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); + + trigChoice = getTrigonometricChoice(); switch (trigChoice) { case 1: // Sine