Browse Source

refactoring: Extracted the scientific options from the scientificMode and move them into getScientificModeChoice

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

22
src/main/c/scientificMode.c

@ -4,6 +4,19 @@
#include <math.h> #include <math.h>
#include "taschenrechner.h" #include "taschenrechner.h"
// Choice for ScientificMode
int getScientificModeChoice() {
int choice;
printf("Scientific mode Options:\n");
printf("1: Square root\n");
printf("2: Exponential\n");
printf("3: Logarithm\n");
printf("4: Trigonometric\n");
printf("0: Exit\n");
scanf("%d", &choice);
return choice;
}
// Choice for Logarithm // Choice for Logarithm
int getLogarithmChoice() { int getLogarithmChoice() {
int logChoice; int logChoice;
@ -16,6 +29,7 @@ int getLogarithmChoice() {
return logChoice; return logChoice;
} }
// Choice for Trigonomtri
int getTrigonometricChoice() { int getTrigonometricChoice() {
int trigChoice; int trigChoice;
printf("Trigonometric functions:\n"); printf("Trigonometric functions:\n");
@ -99,13 +113,7 @@ int scientificMode(){
printf("Enter a number: "); printf("Enter a number: ");
scanf("%lf", &num); // scan the number from the user scanf("%lf", &num); // scan the number from the user
printf("Scientific mode Options:\n");
printf("1: Square root\n");
printf("2: Exponential\n");
printf("3: Logarithm\n");
printf("4: Trigonometric\n");
printf("0: Exit\n");
scanf("%d", &choice); // user choice
choice = getScientificModeChoice();
int logChoice, trigChoice; // Move the initialization outside the loops int logChoice, trigChoice; // Move the initialization outside the loops

Loading…
Cancel
Save