+ 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?

15th Dec 2020, 4:21 AM
A͢J
A͢J - avatar
5 odpowiedzi
+ 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.
15th Dec 2020, 4:30 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
Copy and paste didn’t work for me. But manually typing”Error: division by zero” solved the problem
11th Aug 2022, 6:15 AM
Zoe Piper
Zoe Piper - avatar
+ 1
CarrieForle Thanks. It was very strange. Sololearn post problems without checking. Today, I have reported 2 C# problem.
15th Dec 2020, 4:52 AM
A͢J
A͢J - avatar
+ 1
Kevin ★ Thanks for Explanation. Some characters looks same so anyone can be confused.
15th Dec 2020, 4:54 AM
A͢J
A͢J - avatar