Question: For this project, you are required to build a simple calculator simulator in C++. You are required to implement all operations (explained in this document)
For this project, you are required to build a simple calculator simulator in C++.
You are required to implement all operations (explained in this document) as
separate functions
. Each
function will be responsible for one mathematical operation. C++ has a very convenient mathematical library,
but unfortunately you
cannot
use it
.
So, you need to write your own function for each operation. The code for
the functions that implement root, power, LCM (least common multiple), and GCD (great common divisor) is
given at the end of this document. You are ALLOWED to copy and paste those functions into your project and
use them.
The user must choose which operation she/he will perform based on a menu option displayed. Once an
operation is selected and performed the program should again display the menu. This shall happen until the
user selects the quit option. It is required to display a welcome message when the program starts and
exit message when exiting. Both must be implemented as functions that return the messages as strings. If
no correct menu option is selected the user will be asked for a valid input until they do so.
Operations:
addition, subtraction, multiplication, division, root
a
, power
b
, percentage
c
, least common
multiple
d
, greatest common divisor
d
and modulus;
a =
The user must specify the number and the nth-root desired: see algorithm in the end of this document.
b =
the user must specify the exponent a
n
, where a and n will be provided by the user, and must be
positive
c =
in the format of X% of N, where N is a number and X the requested percentage of that number (It is up to
you how to handle the input, as long it is correct)
d
= assume that these operations work only with positive integers
The next page shows an example of menu and execution shown to the user.
----------------------------------------------------------------------
WELCOME TO THE CALCULATOR PROJECT
----------------------------------------------------------------------
A.) Addition
B.) Subtraction
C.) Multiplication
D.) Division
E.) Roots (only positive number)
F.) Power (only positive number)
G.) Percentage
H.) Least Common Multiplier
I.) Greatest Common Divisor
J.) Modulus
K.) Display function execution*
L.) Quit
----------------------------------------------------------------------
Please select an operation: A
Please provide the first number: 2
Please provide the second number: 3
Operation: 2 + 3 = 5
----------------------------------------------------------------------
WELCOME TO THE CALCULATOR PROJECT
----------------------------------------------------------------------
A.) Addition
B.) Subtraction
C.) Multiplication
D.) Division
E.) Roots (only positive number)
F.) Power (only positive number)
G.) Percentage
H.) Least Common Multiplier
I.) Greatest Common Divisor
J.) Modulus
K.) Display function execution*
L.) Quit
----------------------------------------------------------------------
Please select an operation:
Constraints:
Root/Power operations shall not work with negative numbers the user must be notified of that and
ask for a new input until a proper one is provided.
Division - there is no division by 0 (zero) the user must be notified of that and ask for a new input.
All the operations, except where specified, must work for any Real number.
Every function (including main) must contain: Author name, creation date, last modification date,
purpose (standard comment headers).
DO NOT
use math libraries (e.g. math.h, cmath) This will result in a 75% penalty.
Required Test Cases: minimum 20 cases + Menu:
o
Addition (2)
o
Subtraction (2)
o
Multiplication (2)
o
Division (2 one must handle 0 as input in b for a/b)
o
Root (2)
o
Percentage (2)
o
Exponent (2)
o
LCM (2)
o
GCD (2)
o
Modulus (2)
o
Welcome
o
Exit
No global variables are allowed except constants
Only functions main, menu, and display menu execution option may have any input or output
statements.
BONUS POINTS (3 points):
Design a function that will display which operations were executed (option K in the menu). Indicate where your process does this and provide the combination of execution operations
that resulted in this output (use the summary table to indicate and comments in your code)
----------------------------------------------------------------------
DISPLAYING FUNCTION EXECUTION
----------------------------------------------------------------------
Addition Executed
Subtraction Function Skipped
Multiplication Executed
Division Function Skipped
Roots Executed
Power Executed
Percentage Executed
LCM - Executed
GCD - Executed
Modulus - Function Skipped
----------------------------------------------------------------------
If the function was not executed the status for that function should appear as Function Skipped. For
example, if function Roots and Addition were the only ones not executed the report would appear thusly:
---------------------------------------------------------------------
DISPLAYING FUNCTION EXECUTION
---------------------------------------------------------------------
Addition Function Skipped
Subtraction Executed
Multiplication Executed
Division Executed
Roots Function Skipped
Power Executed
Percentage Executed
LCM - Executed
GCD - Executed
Modulus - Executed
--------------------------------------------------------------------
THIS HAS BEEN POSTED AND ANSWERED BEFORE BUT J AND K HAVE NOT BEEN DONE, ONLY NEED HELP WITH THOSE.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
