+ 6
[Solved] : Code Coach Problem (Multiple Exception) - What is wrong? Test case output or this code?
Here is the code. Output is coming right (in case of Arithmetic Exception) but still no success. Sololearn said we have solved the issue. try { int num1 = scanner.nextInt(); int num2 = scanner.nextInt(); System.out.print(num1 / num2); /* 1. Еrror: division by zero 2. Error: wrong value type */ //your code goes here } catch(ArithmeticException e) { System.out.print("Error: division by zero"); } catch(InputMismatchException e) { System.out.print("Error: wrong value type"); } See and tell what is wrong in this code?
5 Respuestas
+ 2
This is somewhat strange. You can't type the error message at catch(ArithmeticException e) directly. Instead, you need to copy and paste the message from the question or the comment in the code. Then the test case will be passed.
+ 2
Copy and paste didn’t work for me. But manually typing”Error: division by zero” solved the problem
+ 1
CarrieForle Thanks. It was very strange. Sololearn post problems without checking. Today, I have reported 2 C# problem.
+ 1
Kevin ★ Thanks for Explanation. Some characters looks same so anyone can be confused.