+ 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"); } } }
15 Antworten
+ 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.
+ 1
All right 👍
+ 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");
}
}
+ 1
Not working either? 😄 Change the order in which the threads are started. That is, start the one with the first output first.
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.
0
Yes, I'd copied the text but still didn't work, how else can I change the ASCII type?
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.
0
It's not working on mobile, lemme try on laptop on the web version
0
Thank you so much, it worked on web version.
0
You're welcome :)
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?!
0
Oh ok sir/ma thanks a lot
0
You're welcome again :)
0
👌
- 3
Thank you, again boss