title: Java how to run program in a loop and keep counts
body: <p>I created a quiz program that keeps track of students score. What I am trying to do is if the student received 100% then they get a message that their score is 100%. If the the score is less than 100 then the program should restart and keep the counter of up to 5 tries in the counter integer.</p>
  
  <p>Once the counter reaches int of 5 with the score of less than 3 than break the program and display message "take a quiz later"  </p>
  
  <p>What is working right now:
  I am able to keep track of the "score" int variable and its working if you get 100% or less than 100%. </p>
  
  <p>What I am trying to get working:
  Get the "counter" int variable working to keep the record of the number of tries so the user gets up to 5 tries and restart the whole console program while maintaining the score on the "counter" variable.
  for instance:</p>
  
  <pre><code>counter &lt; 5 - try again 
       counter++
  counter &gt;= 5 - end the program.
  </code></pre>
  
  <p>Here is the end of the program. Maybe I should somehow place it in the method and recall it in my public void run but I was unable to accomplish that and keep record of scores. I have many loops so it would be unrealistic to write the whole program in loop one big loop.</p>
  
  <p>Thanks!</p>
  
  <pre><code>   public void run()
      {
          if (score &gt;= 3) 
              {
              println("You have passed the exam with 100%");
              }   
                  else if (counter&lt;5) 
                  {
                  counter++;
                  println("You're score is less than 100%.");
                  println(" ");
                  println("Try Again!");
                  //restart the questions until you're out of 5 attempts
                  } 
                      else if (counter==5)
                      {
                          println("You're out of your 5 attempts");
                      }
      }
  </code></pre>