title: I am need assistance with the next steps in Java loop
body: <p>I am working to create a program in JOptionPane where the computer guesses the users number from 0-999 then with interaction with the user, finally guesses the number (or identifies the user is cheating) then outputs a congratulations screen with the amount of guesses it took and a message.</p>
  
  <pre><code>import javax.swing.JLabel;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.JTextField;
  
  public class GuessMyNumber
  {
  
      public static void main(String[] args)
      {
          //Prepare
          Object[] options1 = { "Yes", "No",
                  "I'm Thinking" };
  
          JPanel Name = new JPanel();
          Name.add(new JLabel("Do you want to play a game? \n"+"\n Please         Enter Your Name"));
          JTextField textField = new JTextField(10);
          Name.add(textField);
  
          int person = JOptionPane.showOptionDialog(null, Name, null,
                  JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
                  null, options1, null);
          if (person == JOptionPane.YES_OPTION)
          {
              JOptionPane.showMessageDialog(null, "Awesome! Nice to meet    you,"+textField.getText()+",Select 'OK' so I can tell you the rules");
              }
      if (person == JOptionPane.NO_OPTION){
          JOptionPane.showMessageDialog(null, "Ok dude, take it easy! I was just asking, geez");
      }
      if (person == JOptionPane.CANCEL_OPTION)
      {
          JOptionPane.showMessageDialog(null, "Hey dude, we do not have all day... HURRY UP");
      }
  
      //Instructions
      else if (person==JOptionPane.YES_OPTION)
      {
      JOptionPane.showMessageDialog(null, "OK  "+textField.getText()+ "\nThe name of the game is for me to guess your number.\n"+"First and foremost, I need you to think of a number from 0 to 999.\n"+"I will then provide you with a number, you need to tell me if I am too LOW or too HIGH, or if I am RIGHT and guessed correctly.\n"+"Are you ready?  If so, make sure you remember your number!", "RULES", JOptionPane.INFORMATION_MESSAGE);
      }
  
      //Game Start
       Object[] options2 = { "Too LOW", "Too HIGH",
              "You Are CORRECT" };
  
      int result = ((999+0)/2);
      int g1=JOptionPane.showOptionDialog(null, "Is your number   "+result+"?", null,
                      JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
              null, options2, null);
      //Guess 1 Low
      if (g1==JOptionPane.YES_OPTION)
      {
          int ga = ((999+result)/2);
  
          int g1a=JOptionPane.showOptionDialog(null, "Is your number   "+ga+"?", null,
                                  JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
              null, options2, null);
  
  
      }
      //Guess 1 High
      else if (g1==JOptionPane.NO_OPTION)
      {
          int gb =((result+0)/2);
  
          int g1b=JOptionPane.showOptionDialog(null, "Is your number   "+gb+"?", null,
                                  JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
              null, options2, null);
  
      }
  
      else if (g1==JOptionPane.CANCEL_OPTION)
      {
          JOptionPane.showMessageDialog(null, "Awesome "+textField.getText()+ ", this was fun!\n"+"For a second there I really thought you had me stumped!\n"+"If you would like to play again, please restart the program.\n"+"Thank you for Playing!", " I GUESSED YOUR NUMBER!", JOptionPane.INFORMATION_MESSAGE);
          System.exit(0);
      }
      //Guess 2
  
  
      }
  }
  </code></pre>