RosettaCodeData/Task/Detect-division-by-zero/NetRexx/detect-division-by-zero.net...

24 lines
676 B
Plaintext

/* 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