title: Input (Scanner) variable in while loop
body: <p>Im trying to make the program to ask for a percentage (grade) but I want it to ask again after the user has made the first input and has seen the output. I'm having trouble with the loop because the variable myMark is no assigned. </p>
  
  <pre><code>import java.util.Scanner;
  public class passFail{
  
  
      public static void main(String[] args){
  
          Scanner result = new Scanner(System.in);
          int myMark = 0;
  
          while(myMark &gt;=0 &amp;&amp; myMark &lt;=100){
  
              System.out.println("Please enter the percentage you have received:");
              myMark = result.nextInt();
  
              if(myMark &lt;=49 &amp;&amp; myMark &gt;=0){
  
                  System.out.println("You have failed!");
              }
  
              else if(myMark &lt;=59 &amp;&amp; myMark &gt;=50){
                  System.out.println("You have passed!");
              }
  
              else if(myMark &lt;=69 &amp;&amp; myMark &gt;=60){
                  System.out.println("You have received a Credit");
              }
  
              else if(myMark &lt;=79 &amp;&amp; myMark &gt;=70){
                  System.out.println("You have received a Distinction!");
              }
  
              else if(myMark &lt;=100 &amp;&amp; myMark &gt;=80){
                  System.out.println("You have received a High Distinction");
              }
  
              else{
                  System.out.println("Please enter a whole number");
              }
  
  
          }
  
      }
  
  
  }
  </code></pre>