hi guys so when I enter a valid number that is not 0 the try and catch block still gets called and it prints cannot divide by zero even when x and y are not equal to zero,what is happening? and how do i fix it
thanks guys just a quick question on the same note how come I cannot put result = x/y; after the try catch block? it tells me that it's not declared in this scope
I see that in this code, even if you detect that y is zero and that you are thus going to try to divide by zero, you still actually try to do a divide by zero.
If you detect that there is going to be a divide-by-zero, you should then not do the divide-by-zero.