I'm trying to create a Java program that prompts the user to enter a number well guess the number with a void method called CheckNum (int num) and the decision statements in the void method CheckNum, checks if the number entered is 100, if that is true, the following message “Number is correct!"
So far this is what I have created:
import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        checkNum();
    }
    public static void checkNum()
    {
        System.out.println("Enter a number: ");
        int guess= sc.nextInt();
        int number=(int)(Math.random()*100)+1;
        System.out.println("The number is "+number);
        if(guess>=1 && guess<=100)
        {
            if(guess==number)
                System.out.println("The number is right!");
            else
                System.out.println("Wrong!");
        }
        else
        {
            System.out.println("Make it a 1-100 please!");
            checkNum();
        }
    }
}