title: Smallest and Second Smallest of a number list
body: <p>Problem 2
  Write your program in the file TwoSmall.java.</p>
  
  <p>Input a set of positive integers, ending with -1 as a sentinel. Print the smallest and second smallest of these numbers in that order.</p>
  
  <p>You may assume there are always at least two numbers before the -1; you do NOT have to check for this being true.</p>
  
  <pre><code>public class TwoSmall{
  
      public static void main(String [] args){
          int min;
          int secondMin;
          int sentinel = -1;
  
          System.out.println("Enter atleast two numbers");    
          int input = IO.readInt();
  
          min = input;
          secondMin = input;
  
          do{
  
                  if(input &lt; min){
                      secondMin = min; 
                      min = input;
                  }
  
                  else if (input &lt; secondMin) {
                      secondMin = input; 
                  }
                  input = IO.readInt();
              } while(input!=sentinel);
  
              System.out.println(min);
              System.out.println(secondMin);
      }
  
  }
  </code></pre>
  
  <p>This is not working? Could someone tell me what is wrong with this program?</p>