Question: Write a php program that implements the following procedures from class: add your function should be named add and should add two numbers together it
Write a php program that implements the following procedures from class:
- add
- your function should be named "add" and should add two numbers together
- it must be able to handle negative numbers
- use the algorithm from class
- subtract
- again, name it "subtract"
- it must be able to handle negative numbers
- use the algorithm from class
- mult
- named "mult"
- must handle negative numbers
- must use the algorithm from class
- exponential
- named "exponential"
- only handle positive exponents, but handle negative bases.
- must use the algorithm from class
At the very end of your file, add the following code, to make sure everything works:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
echo " 6 + 5 = " . add(6,5); echo " 0 + 2 = " . add(0,2); echo " 8 + -4 = " .add(8,-4); echo " 6 -5 = " . subtract(6,5); echo " 0 -2 = " . subtract(0,2); echo " 8 - -4 = " .subtract(8,-4); echo " 6 * 5 = " . mult(6,5); echo " 0 * 2 = " . mult(0,2); echo " 8 * -4 = " . mult(8,-4); echo " 2 ^^ 5 = " . exponential(2,5); echo " -2 ^^ 5 = " . exponential(-2,5);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
