线程 *main* java.util.InputMismatchException中的异常


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);
    }

}

我不确定为什么我的代码中不断出现此错误。我的代码有什么问题?

momH= kb.nextInt((; 是错误的,因为 datatytpe "momH" 和 "dadH" 和 "x" 是双精度数据类型,而不是整数。

*

您应该将 nextInt(( 更改为 nextDouble((;

*

相关内容

  • 没有找到相关文章

最新更新