From 0649393e9383ad67e3e40fb5beaf8a7f1b9b84fd Mon Sep 17 00:00:00 2001 From: fdai7782 Date: Thu, 1 Feb 2024 12:03:47 +0000 Subject: [PATCH] Added calculator modes functionality --- src/main/c/main_taschenrechner.c | 28 ++++++++++++++++++++++++++++ src/main/c/taschenrechner.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/main/c/main_taschenrechner.c b/src/main/c/main_taschenrechner.c index 74668c7..d4549dc 100644 --- a/src/main/c/main_taschenrechner.c +++ b/src/main/c/main_taschenrechner.c @@ -20,3 +20,31 @@ int multiply(int a, int b) { int divide(int a, int b) { return a / b; } + +int mode(int userChoice){ + + switch(userChoice) { + + case 1:return 1; // Basic mode + break; + + case 2:return 2; // Scientific mode (Trigonomertic functions, Logarithm and exponential functions.) + break; + + case 3:return 3; // Graph mode (Draw and visualize functions.) + break; + + case 4:return 4; // Programming mode (Binary , octal and hexadecimal ) + break; + + case 5:return 5; // Unit converter mode (length, weight volume etc.) + break; + + case 0: return 0; // printf("Exiting the calculator.\n"); + break; + + default: return -1; // printf("Invalid choice. Please try again.\n"); + + } + +} \ No newline at end of file diff --git a/src/main/c/taschenrechner.h b/src/main/c/taschenrechner.h index 3147d9d..d410b22 100644 --- a/src/main/c/taschenrechner.h +++ b/src/main/c/taschenrechner.h @@ -9,4 +9,6 @@ int multiply(int a, int b); int divide(int a, int b); +int mode(int userChoice); + #endif // TASCHENRECHNER_H