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


}

I'm not sure as to why I keep getting this error in my code. What's wrong with my code?

PM 77-1
  • 12,933
  • 21
  • 68
  • 111
  • 2
    Post the stack trace. What are you typing as an input when the program ask you for the heights? – Simone Gianni Sep 03 '14 at 02:30
  • Did you mean to use `kb.nextDouble()`? – PM 77-1 Sep 03 '14 at 02:32
  • 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.nextInt(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at Myth.Practice.heightEstimator(Practice.java:11) at Myth.Practice.main(Practice.java:29) – hugotherobot Sep 03 '14 at 02:35
  • just kidding I solved the problem, thank you very much for your help! It was indeed the nextInt that was messing it up, haha sorry i'm still new to coding – hugotherobot Sep 03 '14 at 02:36
  • did you use `nextdouble()` or `nextDouble()` – Jonathon Anderson Sep 03 '14 at 02:38

1 Answers1

0

momH= kb.nextInt(); is wrong because datatytpe "momH" and "dadH" and "x" is a double datatype, and not integer.

*

You should change nextInt() to nextDouble();

*

CuriousDev
  • 17
  • 2