Task

Write a function to detect a   divide by zero error   without checking if the denominator is zero.




/* NetRexx */
options replace format comments java crossref symbols nobinary
 
method divide(dividend, divisor) public constant returns Rexx
  do
    quotient = dividend / divisor
  catch exu = DivideException
    exu.printStackTrace()
    quotient = 'undefined'
  catch exr = RuntimeException
    exr.printStackTrace()
    quotient = 'error'
  end
  return quotient
 
method main(args = String[]) public static
  -- process input arguments and set sensible defaults
  arg = Rexx(args)
  parse arg dividend .',' divisor .
  if dividend.length() = 0 then dividend = 1
  if divisor.length()  = 0 then divisor  = 0
  say dividend '/' divisor '=' divide(dividend, divisor)
  return
 