0
我是Java新手,正在尝试制作一个程序,以查看一个人是否具有正常温度,而不是太低或太高。错误java.util.InputMismatchException
我已经收到此错误信息:(我'输入时双,而不是INT)
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextDouble(Unknown Source)
at ekstra217.main(ekstra217.java:15)
这里是我的代码
import java.util.*;
class temp
{//klassen start
public static void main(String[]args)
{//main start
Scanner tast=new Scanner(System.in);
System.out.println("Write your temperatur!");
//normal temperatur is between 36.5 and 37.5
double temperatur=tast.nextDouble();
if (temperatur<36.5)
{
System.out.println("Your temperatur is normal");
}
else if(temperature>37.5)
{//else if starts
System.out.println("You have over normal,you are sick");
}//else if slutter
else{
System.out.println("You have normal temperature");
}
}
}
你在标准输入进入? –
您的标题非常误导,我建议您将其更改为包含“java.util.InputMismatchException” – VirtualTroll
的东西请记住,指定双值时,逗号分隔符为'。'。 (点)而不是','(逗号),就像我们在挪威习惯的那样);这也适用于通过命令行指定的值。 – Tobb