'Input from a method gets stuck in java

In this method, it prompts the user to enter the value of their insured home. For some reason, it is getting stuck when the user inputs

static double promptHomeInsVal(){
        double homeInsVal;
        className promptHomeInsVal = new className();
        do{
            do{
                System.out.printf("%nPlease enter the insured value of your home:  ");
                homeInsVal = promptHomeInsVal.input.nextDouble();
                validateNumber(!promptHomeInsVal.input.hasNextDouble());
            }while(promptHomeInsVal.repeat == true);
            homeInsVal = promptHomeInsVal.input.nextDouble();
            if(homeInsVal <= 0){
                System.out.println("The insured value of your home cannot be less than or equal to 0. ");
                promptHomeInsVal.repeat = true;
            }
            else{
                promptHomeInsVal.repeat = false;
                System.out.println("Home insurance value == " + homeInsVal);
            }
        }while(promptHomeInsVal.repeat == true);

        return homeInsVal;
    }

Here is validateNumber()

static void validateNumber(boolean repeat){
        className validateNumber = new className();
        if(repeat == true){
            System.out.println("Warning:  You entered an invalid integer or floating-point value. ");
        }
    }

When the prompt comes up "Please enter the insured value of your home: " it is suppose to take the input and move on. Right now, it is getting stuck



Solution 1:[1]

I feel that a significant part of the code is missing, and as far as I can see the problem should be in that part of the code. You should include into your question the code of the class className (which seems to be an error by itself).

In addition to that, I see some minor coding style mistakes in your code. You did not ask for such advice, but let me note that anyBooleanVariable == true is just the same as anyBooleanVariable.

Also validateNumber is the name of a method and the same time the name of a local variable inside the same named method. It is possible, but this is confusing and not a recommended practice.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Verhas