title: Do while loop repeats twice, doesn't follow conditions
body: <p>I am new to Java and I've run into a bit of a problem. My instructor requires that I nest a do while loop within a while loop; the do while loop creates restrictions for the type of grade the user can input (more than 0 but less than 100) for the midterm, final and project grades. This input is then used in a calculation for the average of those three grades. </p>
  
  <p>However, my do while loop runs twice and uses the input from the second prompt in the calculation for average. What am I doing wrong? I've gone through my textbook and this site, but I can't seem to understand why it's doing this since it's only prompting twice and then only using the input for the second prompt. Any help would be greatly appreciated. Thank you for taking the time to read my post!</p>
  
  <p>For clarification, here is my code:</p>
  
  <pre><code>System.out.println("******** Step 2: Grading for Multiple Students *********");
      System.out.println();
      // Create scanner object for text and number
      Scanner textReader = new Scanner(System.in);
      Scanner numberReader = new Scanner(System.in);
      System.out.print("Would you like to input grades (y/n): ");
      String response = textReader.nextLine();
      // Create while loop for first yes/no question
      while ((!response.equalsIgnoreCase("y")) &amp;&amp; (!response.equalsIgnoreCase("n")))
      {
          System.out.print("y/n needed: ");
          response = textReader.nextLine();
          System.out.println();
      }
      while ((response.equalsIgnoreCase("y")))
      {
          System.out.print("\nStudent Name: ");
          String studentName = textReader.nextLine();
          System.out.print("Course Name: ");
          String courseName = textReader.nextLine();
          System.out.print("Midterm Grade (needs to be between 0-100): ");
          double midtermGrade = numberReader.nextDouble();
          do
          {
              System.out.print("Midterm Grade (needs to be between 0-100): ");
              midtermGrade = numberReader.nextDouble();
              break;
          }
          while ((midtermGrade &lt; 0) || (midtermGrade &gt; 100));
          System.out.print("Final Grade (needs to be between 0-100): ");
          double finalGrade = numberReader.nextDouble();
          do
          {
              System.out.print("Final Grade (needs to be between 0-100): ");
              finalGrade = numberReader.nextDouble();
          }
          while ((finalGrade &lt; 0) || (finalGrade &gt; 100));
          System.out.print("Project Grade (needs to be between 0-100): ");
          double projectGrade = numberReader.nextDouble();
          do
          {
              System.out.print("Project Grade (needs to be between 0-100): ");
              projectGrade = numberReader.nextDouble();
          }
          while ((projectGrade &lt; 0) || (projectGrade &gt; 100));
  </code></pre>
  
  <p>And here is my output:</p>
  
  <p><a href="https://i.stack.imgur.com/E2KfM.png" rel="nofollow noreferrer">Output link</a></p>