java - Error with user input within calculator program -
this code used calculator program.
package javaapp; import java.util.scanner; public class javaapp { public static void main(string args[]){ scanner matt = new scanner("system.in"); double fnum; double snum; double answer; system.out.println("enter first number: "); fnum = matt.nextdouble(); system.out.println("enter second number: "); snum = matt.nextdouble(); answer = fnum + snum; system.out.println(answer); } }
this error:
exception in thread "main" java.util.inputmismatchexception @ java.util.scanner.throwfor(scanner.java:909) @ java.util.scanner.next(scanner.java:1530) @ java.util.scanner.nextdouble(scanner.java:2456) @ javaapp.javaapp.main(javaapp.java:10) java result: 1
remove quotes constructor of scanner
it's not attempting read string
source
scanner matt = new scanner(system.in);
Comments
Post a Comment