JAVA LOOP FOR GAME : I'm having trouble with my code. For some reason, each time I run the code the " if (guess <1 || guess >10 )
            System.out.println ("Your guess needs to be between 1 and 10");" statement is counted as a guessing attempt. The goal is to not have the attempt count if the player is guessing out of the 1-10 range. I've tried a break;, but I can't get it right? Does anyone know how to break the loop and return to the guessing, if a user is out of range(without it counting as an attempt)?

Thank you 





    import java.security.SecureRandom;
    import java.util.Scanner;

    public class GuessTheNumber {
    private Scanner input = new Scanner(System.in);
    private SecureRandom randomNumbers = new SecureRandom();
    private int numberOfGuesses;
    
    public void play() {
        numberOfGuesses = 0;
        int magicNumber = 1 + randomNumbers.nextInt(10);
        
        int guess = askForGuess();
        
         
        
        while(guess != magicNumber){
        // Some kind of loop, maybe while
        numberOfGuesses++;
        // is theGuess equal to magicNumber or is it
        guess = input.nextInt();
        // too high or is it too low
        
           
        
              
        if (guess == magicNumber)
        System.out.println("Yes, the number is " + magicNumber);
        
      else if (guess > magicNumber)
        System.out.println("Your guess is too high");
        
      else if (guess < magicNumber)
        System.out.println("Your guess is too low");
                
              System.out.println  ("Number of times guessed: "
        + numberOfGuesses );
        // Display "correct in numberOfGuesses"
        
        
         
        }

      }
        
        
    }
    
    private int askForGuess( ) {
       
        int guess = 0;
        
 
         // prompt for a guess
        System.out.println("Enter a number:");
        
        if (guess <1 || guess >10 )
            System.out.println ("Your guess needs to be between 1 and 10");
 
      return guess;
    
 }
 
   }
