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


}

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

4

1 回答 1

0

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

*

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

*

于 2014-09-03T02:56:30.777 回答