0
package Myth;
import java.util.Scanner;
public class Practice
{
public static void heightEstimator(double momH, double dadH)
{
Scanner kb= new Scanner(System.in);
System.out.println("Enter your Mothers Height in Feet: ");
momH= kb.nextInt();
System.out.println("Enter your Fathers Height in Feet: ");
dadH= kb.nextInt();
double w= (dadH+momH)/2;
System.out.println("You will be "+ w+ "Ft.");
}
public static int shoeSize(double x)
{
Scanner z= new Scanner(System.in);
System.out.println("Enter your Fathers Heigh in Inches: ");
x= z.nextInt();
double y= x/6;
System.out.println("Your shoe size will be: "+ y);
return 0;
}
public static void main(String[] args)
{
heightEstimator(0, 0);
shoeSize(0);
}
}
我不知道为什么我一直在我的代码中得到这个错误。我的代码有什么问题?线程*主要异常* java.util.InputMismatchException
后的堆栈跟踪。当程序问你高度时,你输入什么作为输入? – 2014-09-03 02:30:00
你的意思是使用'kb.nextDouble()'? – 2014-09-03 02:32:45
异常在线程 “主” java.util.InputMismatchException \t在java.util.Scanner.throwFor(未知来源) \t在java.util.Scanner.next(未知来源) \t在java.util.Scanner.nextInt (来源不明) \t在java.util.Scanner.nextInt(来源不明) \t在Myth.Practice.heightEstimator(Practice.java:11) \t在Myth.Practice.main(Practice.java:29) – hugotherobot 2014-09-03 02:35:07