title: Find two smallest value inputs
body: <p>The instructions are: "Ask the user for the following information, in this order:</p>
  
  <ul>
  <li>A terminating value (real number). The user will enter this value again later, to indicate that he or she is finished providing input.</li>
  <li>A sequence of real numbers. Keep asking for numbers until the terminating value is entered.</li>
  <li>Compute and output the smallest and second-smallest real number, in that order. It is possible for the smallest and second-smallest numbers to be the same (if the sequence contains duplicate numbers)."</li>
  </ul>
  
  <p>I uploaded my code and the grading software gave me a zero saying the program is not consistent with the assignment, however, when testing my code it runs just as required for the assignment. Any feedback as to why this may happen would be appreciated.</p>
  
  <p>This is my code:</p>
  
  <pre><code>public class TwoSmallest
      {
      public static void main (String[] args)
      {
          double terminator;
          System.out.print ("Please enter a terminating value: ");
          terminator = IO.readDouble();
  
          double lowest1;
          double lowest2;
          System.out.println("Please enter sequence of numbers:");
          lowest1 = IO.readDouble();
          while (lowest1 == terminator)
          {
              IO.reportBadInput();
              lowest1 = IO.readDouble();
          }
          lowest2 = IO.readDouble();
          while (lowest2 == terminator)
          {
              IO.reportBadInput();
              lowest2 = IO.readDouble();
          }
          double input;
          do
          {
              input = IO.readDouble();
              if (input &lt; lowest1)
              {
                  if(lowest2 &lt; lowest1)
                      lowest2 = lowest1;
                  lowest1 = input;
              }
              else if (input &lt; lowest2)
                  lowest2 = input;
          }while (input != terminator);
  
          System.out.println("RESULT: " + lowest1);
          System.out.println("RESULT: " + lowest2);
      }
  }
  </code></pre>