Actions Problems

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14

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.

Coding:

Blocks

PreviousNext