Write methods for following arithmatic operations, each method takes 2 inputs the first operand and the second operand:
- Addition
- Subtraction
- Multiplication
- Divide
Write a method that asks the user for the 2 operands and the operation they want to perform, and accordingly calls the corresponding method and displays the result.
Add the Method Power as one of the mathmatical operations that your calculator accepts. (This is the symbol used for power ^
) Implement the method for power using 2 different ways:
- Search for a predefined method to calculate the power
- Implement the power using multiplication such that
m^n = m*m*m..*m (ntimes) i.e. 2^4 = 2*2*2*2