getInt

   //
   //
   // Author : wyatt
   // Purpose: read an integer between a specified range
   /* Design (algorithm): (the 'recipe': the steps to solve the problem)      
      loop
         read input  
         if bad
            clear stream error flags
            dump the buffer of 100 bytes or until it sees return char 
      while input is bad      

   */

   int getint(int min, int max)
   {
      bool fail;
      int num;
      do
      {  
         fail = false;
         cout << "Enter an integer between " << min << " and " <<  max << ": ";
         cin >> num;
         // fail is if previous input was bad
         if( cin.fail() || cin.eof()  || num<min || num>max )
         {
            cin.clear();          // clears ERROR flags
            cin.ignore(100,'\n');  // dump the buffer - 100 seems arbitrarily big enough, but kludgey
            fail = true;
         }
      } while(fail);
      return num;
   }