From 2957ef2229781820daca43b1513dec5de869f3ed Mon Sep 17 00:00:00 2001 From: Ulriche Nguefack Date: Wed, 7 Feb 2024 14:41:11 +0100 Subject: [PATCH] refactoring: case(geting user input for both int and double) --- src/main/c/Calculator/calculator.c | 40 +++++++++--------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c index 193ed38..1ddf5fe 100644 --- a/src/main/c/Calculator/calculator.c +++ b/src/main/c/Calculator/calculator.c @@ -115,32 +115,16 @@ double combination(int n, int r); return 0.0; } } +double getDoubleInput(const char *message) { + double input; + printf("%s", message); + scanf("%lf", &input); + return input; +} - - - double power(double base, double exponent) { - return pow(base, exponent); - } - - double sine(double angle) { - return sin(angle * M_PI / 180.0); - } - - double cosine(double angle) { - return cos(angle * M_PI / 180.0); - } - - double tangent(double angle) { - return tan(angle * M_PI / 180.0); - } - double permutation(int n, int r) { - int result = 1; - for (int i = 0; i < r; i++) { - result *= (n - i); - } - return result; - } - - double combination(int n, int r) { - return permutation(n, r) / factorial(r); - } \ No newline at end of file +int getIntInput(const char *message) { + int input; + printf("%s", message); + scanf("%d", &input); + return input; +}