From 4518b70777905fbf7e476ac4bc5ac38fc2ef3e03 Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Tue, 6 Feb 2024 17:21:10 +0000 Subject: [PATCH] refactoring: Extracted the logarithm options from the executeLogarithmFunction and move them into getLogarithmChoice function --- src/main/c/scientificMode.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/c/scientificMode.c b/src/main/c/scientificMode.c index ddf2c7e..0a7d37a 100644 --- a/src/main/c/scientificMode.c +++ b/src/main/c/scientificMode.c @@ -4,17 +4,26 @@ #include #include "taschenrechner.h" +// Choice for Logarithm +int getLogarithmChoice() { + int logChoice; + 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); + return logChoice; +} + + // 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); + + logChoice = getLogarithmChoice(); switch (logChoice) { case 1: // Logarithm (base 10)