- 1

No Zeros Java Exercice: solution right, Sololearn wrong?

The code gives the right answer yet sololearn takes it as wrong

22nd May 2022, 10:17 AM
Norberto Costa
Norberto Costa - avatar
4 odpowiedzi
+ 1
JAVA exercice NO ZEROS in Java learning. Exceptions handling.
22nd May 2022, 10:22 AM
Norberto Costa
Norberto Costa - avatar
+ 1
Norberto Costa 58.2 of the Java tutorial
22nd May 2022, 10:27 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Norberto Costa Please identify exactly which challenge you are attempting, and post your attempt here so we may review.
22nd May 2022, 10:20 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
import java.util.Scanner; import java.util.InputMismatchException; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); try { int num1 = scanner.nextInt(); int num2 = scanner.nextInt(); /* 1. Еrror: division by zero 2. Error: wrong value type */ //your code goes here System.out.println (num1/num2); } catch(ArithmeticException ex) { System.out.println ("Error: division by zero"); } catch(InputMismatchException ex){ System.out.println ("Error: wrong value type"); } } }
22nd May 2022, 10:21 AM
Norberto Costa
Norberto Costa - avatar