title: Repeating Methods
body: <p>My program isn't finished yet but I need help in finding a way to run my method 6 times. It is a math drill game where the method does the outputting of the question and calculating of the answer. Ideally id like for the method run 6 times (6 math questions in total), then afterwards output the "LEVEL ONE COMPLETE" statement. But whenever I run it, It outputs "LEVEL ONE COMPLETE" at the end of every question. Also, the amount of money ( <code>int amount = 0;</code>) does not increment ( <code>amount+=150;</code>) each time the user gets the question right. Im a beginner so help would be appreciated!</p>
  
  <p>And just an extra thing.. if I want to have the game end if the user gets 3 wrong answers, how should I go about including it into my code?</p>
  
  <p>Thanks!</p>
  
  <p>This is where I call the method in the the main method.. running it 6 times:</p>
  
  <pre><code>  for (int loop = 0; loop &lt;= 6; loop++) { findAdd() }
  </code></pre>
  
  <p>This is the method which I am calling (contains the math problems):</p>
  
  <pre><code>public static int findAdd ()
   {
     Object[] optionsA = {"Yes Please", "Nope! I'm good!"};
     int wrong = 0;
     int amount = 0;
     int increment = 150;
     int questionnum = 0;
     questionnum ++;
     int numOne = (int)(Math.random () * 30);
     int numTwo = (int)(Math.random () * 30);
     int answer = numOne + numTwo;
  
     String useranswerA = JOptionPane.showInputDialog(null,"Question #" + questionnum + " is for: $" + increment + "\n" + numOne + " + " + numTwo + " = ?", "Question", JOptionPane.INFORMATION_MESSAGE);
      int useranswer = Integer.parseInt(useranswerA);
  
          if (useranswer != answer)
          {
            wrong ++;
            JOptionPane.showMessageDialog(null,"You got the wrong answer! \n The correct answer is: " + answer + " \n Questions Wrong: " + wrong, "Wrong Answer", JOptionPane.INFORMATION_MESSAGE);
            int y = JOptionPane.showOptionDialog(null,"CASH OUT with a total of $" + amount + "?","Cash Out?", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,optionsA,optionsA[0]);
            if (y == JOptionPane.YES_OPTION) {
              JOptionPane.showMessageDialog(null,"Thanks for Playing!", "Thank You!", JOptionPane.INFORMATION_MESSAGE);
              System.exit(0);
            }
            if (y == JOptionPane.NO_OPTION) {}
          }
          else if (useranswer == answer)
          {
            amount+=150;
            JOptionPane.showMessageDialog(null,"Correct!", "Right Answer", JOptionPane.INFORMATION_MESSAGE);
            int y = JOptionPane.showOptionDialog(null,"CASH OUT with a total of $" + amount + "?","Cash Out?", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,optionsA,optionsA[0]);
            if (y == JOptionPane.YES_OPTION) {
              JOptionPane.showMessageDialog(null,"Thanks for Playing!", "Thank You!", JOptionPane.INFORMATION_MESSAGE);
              System.exit(0);
            }
            if (y == JOptionPane.NO_OPTION) {}
          }
  
  
       JOptionPane.showMessageDialog(null,"LEVEL ONE COMPLETE!", "LEVEL 1", JOptionPane.INFORMATION_MESSAGE);
       JOptionPane.showMessageDialog(null,"Cash on Hand: $ " + amount, "Cash", JOptionPane.INFORMATION_MESSAGE);
        return useranswer;
     }
  </code></pre>