Java Lesson 58.1 practice problem won't accept my answer even though it's the same | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Java Lesson 58.1 practice problem won't accept my answer even though it's the same

My program outputs: "Error: division by zero" The expected answer is "Error: division by zero" (this is on the same test) Why won't sololearn accept my answer? And when I want to look at the solution, I can't look at it entirely because I can't scroll down This is my answer: 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(); System.out.println(num1/num2); } catch(ArithmeticException ae) { System.out.println("Error: division by zero"); } catch(InputMismatchException ime) { System.out.println("Error: wrong value type"); } } }

20th May 2022, 2:03 PM
MCS Three
MCS Three - avatar
1 Answer
0
Just try again. Look closely, is there any extra spces.. edit: MCS Three remove and rewrite "Error" in output or copy paste from description.
20th May 2022, 4:37 PM
Jayakrishna 🇮🇳