Question: My java program won't run, the only thing that comes up is in the console. Could you please tell me what I'm doing wrong and

My java program won't run, the only thing that comes up is in the console. Could you please tell me what I'm doing wrong and how to fix it?

import javax.swing.JOptionPane; import java.util.Random;

public class RandomNumberGuessingGame{

public static void main( String [ ] args ) { Random randomObjectNumber = new Random(); int RandomNumber = randomObjectNumber.nextInt( 101 ); boolean NumberEnteredCorrect = false; String userInput; int NumberUserGuessed; int NumberOfTimeUserGuessed = 0; while( NumberEnteredCorrect ) { NumberOfTimeUserGuessed = NumberOfTimeUserGuessed + 1; userInput = JOptionPane.showInputDialog( " Guess the number: " ); NumberUserGuessed = Integer.parseInt ( userInput ); if( NumberUserGuessed > RandomNumber ) { JOptionPane.showMessageDialog( null, " To high, try again" ); }//End of If statement else if(NumberUserGuessed < RandomNumber ) { JOptionPane.showMessageDialog( null, " To low, try again" ); }//End of else if statement else { JOptionPane.showMessageDialog( null, " Good job you guessed the number right."+ NumberOfTimeUserGuessed + " Tries"); NumberEnteredCorrect = true; }//End else statement }//End of while loop System.exit( 0 );

}//End class

}//End main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!