Actions Problems
Math Actions: Divide
For this problem, add a Divide action with two number parameters and a number return value for this problem. In addition, you will need to do some error checking to check if the divisor is zero. If it is zero, output a message Error, cannot divide by zero.
and return 0.0. Otherwise, return the division result.
Once you have completed the action, call the action with the arguments 34.0 and 2.0(e.g., otherResult = Divide(34.0, 2.0)
). Then, output the results. Call the action a second time with arguments 34.0, 0.0 and output the result. When run, the program should output the following.
-6
-2
15
17.0
Error, cannot divide by zero.
0.0.