package lu;
import java.util.Scanner;
public class kkk {
public static void main(String[] args){
Scanner sc= new Scanner (System.in );
double s1=sc.nextDouble();
String s=sc.nextLine();
char op=s.charAt(0);
double s2=sc.nextDouble();
if(op=='/') {
if(Math.abs(s2)<1e-10) {
System.out.print("Wrong input!");
}
System.out.printf("%.2f",s1/s2);
}
else if(op=='*') {
System.out.printf("%.2f",s1*s2);
}
else if(op=='+') {
System.out.printf("%.2f",s1+s2);
}
else if(op=='-') {
System.out.printf("%.2f",s1-s2);
}
else {
System.out.print("Wrong input!");
}
}
}
输入1.0+1.0之后出现以下错误:
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextDouble(Scanner.java:2413)
at lu.kkk.main(kkk.java:11)