import java.util.Scanner;
import java.util.Random;
public class Guesser{

    public Guesser(){

        this.playGame();

    }

    // Random Number to 100
    boolean check = false;
    Random rand = new Random();
    int answer = rand.nextInt(100);

    public static void main(String[] args){

        Guesser guessGame = new Guesser();

    }

    // Function that checks whether or not the guess was correct
    public boolean checker(int guess, int ans){
        if(guess == ans){
            check = true;
        }
        return check;
    }

    public void playGame(){
        Scanner scan = new Scanner(System.in);
        System.out.println("Input your guess: ");
        int inp = Integer.parseInt(scan.nextLine());
        boolean output = checker(inp, answer);
    
        while(output == false){
            if(inp < answer){
                System.out.println("Wrong, guess higher silly goose!");
            }
            if(inp > answer){
                System.out.println("Wrong, guess lower silly goose!");
            }
            System.out.println("Input your guess again: ");
            inp = Integer.parseInt(scan.nextLine());
            output = checker(inp, answer);
        }
    
        System.out.println("You got it right! The answer was: " + answer);
    }
}

Guesser.main(null);
Input your guess: 
Wrong, guess higher silly goose!
Input your guess again: 
Wrong, guess higher silly goose!
Input your guess again: 
Wrong, guess higher silly goose!
Input your guess again: 
Wrong, guess lower silly goose!
Input your guess again: 
Wrong, guess higher silly goose!
Input your guess again: 
Wrong, guess higher silly goose!
Input your guess again: 
Wrong, guess lower silly goose!
Input your guess again: 
Wrong, guess lower silly goose!
Input your guess again: 
You got it right! The answer was: 92