+ 3

Java-multiple exception. My Code Ran Correctly but wasn;t accepted

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"); } } }

26th Apr 2022, 8:46 AM
Micheal Mfon
Micheal Mfon - avatar
15 Respostas
+ 1
Wow ... the thing is, the 'E' in "Error" is not the ASCII 'E', but some Unicode 'E' at a different code point. It is this E: Е Notice a difference? Me neither. To solve, copy the output text from the task description and paste into your code.
26th Apr 2022, 9:44 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
All right 👍
26th Apr 2022, 9:58 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
Please any question on threads error: cannot find symbol class Main { public static void main(String[ ] args) { Name name = new Name(); //set priority name.setPriority(2); Welcome welcome = new Welcome(); //set priority welcome.setPriority(9); name.start(); welcome.start(); } } //extend the Thread class class Welcome extends Thread { public void run() { System.out.println("Welcome!"); } } //extend the Thread class class Name{ public void run() { System.out.println("Please enter your name"); } }
26th Apr 2022, 10:23 AM
Micheal Mfon
Micheal Mfon - avatar
+ 1
Not working either? 😄 Change the order in which the threads are started. That is, start the one with the first output first.
26th Apr 2022, 10:25 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
0
No I don't see the difference, I'm using mobile but got the same error from laptop when I typed out the code on the web platform. So I don't know what I'm expected to do.
26th Apr 2022, 9:46 AM
Micheal Mfon
Micheal Mfon - avatar
0
Yes, I'd copied the text but still didn't work, how else can I change the ASCII type?
26th Apr 2022, 9:49 AM
Micheal Mfon
Micheal Mfon - avatar
0
See this: https://code.sololearn.com/cgyQWC02EOD7 You need the first E. But when you type from keyboard, you get the second E. You need to copy and paste from the task description.
26th Apr 2022, 9:49 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
0
It's not working on mobile, lemme try on laptop on the web version
26th Apr 2022, 9:53 AM
Micheal Mfon
Micheal Mfon - avatar
0
Thank you so much, it worked on web version.
26th Apr 2022, 9:55 AM
Micheal Mfon
Micheal Mfon - avatar
0
You're welcome :)
26th Apr 2022, 10:34 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
0
Please one more question just to better understand what's happening, I get why I had to change the order of the start function to get the desired output. But now, I just commented out the setPrioity() function and I still got the same results. I tested these by giving a higher value to the second line output. So my question, Does it mean the setPrioity function is unnecessary?!
26th Apr 2022, 10:39 AM
Micheal Mfon
Micheal Mfon - avatar
0
Oh ok sir/ma thanks a lot
26th Apr 2022, 10:44 AM
Micheal Mfon
Micheal Mfon - avatar
0
You're welcome again :)
26th Apr 2022, 10:45 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
0
👌
27th Apr 2022, 3:56 AM
Bilal Ahmed
- 3
Thank you, again boss
26th Apr 2022, 10:34 AM
Micheal Mfon
Micheal Mfon - avatar