Runtime exception | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Runtime exception

Is this code is properly written: ____________________________________ import java.util.Scanner; public class MyClass { public static void main(String[ ] args) { Scanner input = new Scanner(System.in); System.out.println ("Insert number to be devided"); double value = input.nextDouble; System.out.println ("Insert number to devide with"); double div = input.nextDouble; try{ value = value / div; System.out.println (value); }catch (ArithmeticException e){ System.out.println("DIV with 0-not possible"); } } } ____________________________________ It should return div of inserted numbers, or "DIV with 0-not possible" if you insert 0 as seccond number.

11th Jan 2017, 1:47 PM
Sasa Potic
Sasa Potic - avatar
1 Answer
+ 2
Please try writing "nextDouble()" instead of "nextDouble". It should compile now.
11th Jan 2017, 2:21 PM
Álvaro