0

My program don't display var4. Why? I make this code. Thank you.

Display division. https://code.sololearn.com/cd8NU5J0hAvN/?ref=app

3rd Jul 2020, 7:07 AM
Malick Diagne
Malick Diagne - avatar
3 ответов
+ 2
Division by zero eror in `Reste` class constructor. Neither <var1> nor <var2> was non zero (both variables value were zero). I'm not sure what you are trying to do here actually.
3rd Jul 2020, 7:20 AM
Ipang
+ 1
Reste () is causing a divide by zero error becuase neither variable is set, you can check this by calling a print statement on both variable before the division happens. Look into making the variables global by using public static then referencing like Division.var1.
3rd Jul 2020, 7:21 AM
JME
+ 1
Malick Diagne Check the output. You are getting Arithmetic Exception. It comes when you divide any number with 0. In these two cases you may get this exception (1) var1 % var2 , (2) var1 / var2. To handle this exception you can use try catch block try { var4 = var1 / var2 ; } catch (ArithmeticException e) { System.out.println("You cannot divide number with 0 value, var4 = " + 0); } Try to debug the code. Read exception and try to know and solve. It will be helpful in further coding.
3rd Jul 2020, 7:27 AM
A͢J
A͢J - avatar