到此代码
public static void main(String[] args) {
Scanner wg= new Scanner(System.in);
System.out.print("Enter your weight on the Earth ");
double weight = wg.nextDouble();
double c;
c=17*weight/100;
System.out.println("Your weight on the Moon is: " + c);
wg.close();
}
问题是什么,当我输入双值时,它向我显示:
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
最佳答案
您肯定使用了无效的 double 格式。例如使用“,”而不是“.”
Enter your weight on the Earth 55,77
Exception in thread "main" java.util.InputMismatchException
关于Java双重错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33984940/