我是 Java 新手,正在尝试制作一个程序来查看一个人的体温是否正常,不会太低或太高。
我一直收到此错误消息:(当我输入双精度而不是整数时)
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");
}
}
}