#include "displayMenuCalculator.h" #include "calculatorGetUserInput.h" #include "calculatorGetUserInputFactorial.h" #include "calculatorAdd.h" #include "calculatorSubtract.h" #include "calculatorMultiply.h" #include "calculatorDivide.h" #include "calculatorFactorial.h" // Note: /* This Function may or may not be implemented in actual program, even if it is merged to the main branch. If it is temporarily not included in the main Program, then this has a role in future Development of the Project */ int operation1 = 1; int operation2 = 2; int operation3 = 3; int operation4 = 4; int operation5 = 5; int check() { const int rConst = 1; // RandomConstant created for indirectly testing void displayMenuCalculator() if(rConst == 1)// RandomConstant created for indirectly testing void displayMenuCalculator() { return 1; } } void displayMenuCalculator(char x) //Displays the correct output, only when x is c. { float num1, num2, answer; //Created for storing numbers for addition, subtraction, multiplication and division and the final answer. int num; //Created specially for calculatorFactorial() int choose; if(x == 'c') //calculator can be activated by adding 'c' in void displayMenuCalculator() { if(check() == 1) { //The Main Menu of the calculator printf(" %d. Add\n", operation1); printf(" %d. Subtract\n", operation2); printf(" %d. Multiply\n", operation3); printf(" %d. Divide\n", operation4); printf(" %d. Factorial\n", operation5); printf("Enter your choice: "); // Takes the choice of operations from the user scanf("%d", &choose); // Saves the choice switch (choose) { //takes user's choice and calls operation-functions accordingly case 1: calculatorGetUserInput(&num1, &num2); answer = calculatorAdd(num1, num2); printf("Answer: %f\n", answer); break; case 2: calculatorGetUserInput(&num1, &num2); answer = calculatorSubtract(num1, num2); printf("Answer: %f\n", answer); break; case 3: calculatorGetUserInput(&num1, &num2); answer = calculatorMultiply(num1, num2); printf("Answer: %f\n", answer); break; case 4: calculatorGetUserInput(&num1, &num2); answer = calculatorDivide(num1, num2); printf("Answer: %f\n", answer); break; case 5: calculatorGetUserInputFactorial(&num); //Created specially for factorial which gets a number from user. answer = calculatorFactorial(num); printf("Answer: %f\n", answer); break; default: printf("Invalid choice\n"); return; } } } }