+ 1

How can 5/2=2 and error divide by 0 at the same time???

In the "Multiple Exceptions" java coach challenge , can any one explain the following: Test case #1 Input 5 2 My output 2 Expect output 2 Test Case #2 Input 5 2 My Output 2 Expected Output Error: division by 0 ............................... How can 5/2 be both 2 and error: division by 0 ????? Please explain. I get all test cases, but #2. The link to The code Is https://code.sololearn.com/cDugQ4EstWIo/?ref=app

22nd Nov 2020, 6:35 AM
Rick Shiffman
Rick Shiffman - avatar
3 Respostas
+ 7
Can we see the task what you're trying to do? Your code is working as expected. I think it's a bug.
22nd Nov 2020, 6:44 AM
Simba
Simba - avatar
+ 2
I've reported to SoloLearn. https://www.sololearn.com/learn/Java/2176/
22nd Nov 2020, 6:47 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
Here is the text of the coach callenge: Multiple Exceptions 10XPs You need to write a divider program which will operate with integers, The program you are given should take two integers as input and execute the division, but we need to handle two exceptions: 1. the divider shouldn't be zero 2. both inputs should be integers. Complete the program to handle them. For the first exception, the program should output "Еrror: division by zero"; and for the second one, "Error: wrong value type". Sample Input 1 b Sample Output Error: wrong value type Use ArithmeticException for first exception and InputMismatchException for the second one.
22nd Nov 2020, 7:18 AM
Rick Shiffman
Rick Shiffman - avatar