A few days ago i posted a topic about if/else and while loops.
I have gotten a bit further and now made a little program to guess a number.
I would like to implement a feature to check if the user has an empty input but i cannot seem to figure it out!
Is there anyone who can help me a bit? Im still a pretty early beginner at JAVA.
Here is my current code:
import  java.util.Scanner;
import  javax.swing.JOptionPane;
/**
 *
 * @author henluu
 */
public class Practice {
    public static void main(String[] args) {
        //create new scanner
        Scanner input = new Scanner(System.in);
        int raad = 0;         
        raad = Integer.parseInt(JOptionPane.showInputDialog("Guess the number"));
        while (Practice.rn() != raad) {
            JOptionPane.showMessageDialog( null, ("Your number is not the same as the random number"));
            raad = Integer.parseInt(JOptionPane.showInputDialog("Guess the number"));
            //empty check
            if (raad == " ") {
                Integer.parseInt(JOptionPane.showInputDialog("No Input"));
            }
        }    
            JOptionPane.showMessageDialog( null, ("You guesse dit right! The number was: ") + Practice.rn());      
        }
    //method to generate random number
    public static int rn() {
        int random = (int) Math.floor((Math.random() * 10) + 1);
        return random;
    }
}
 
     
     
     
    