/******************************************************************************/
/* show use of string comparison                                              */
/* 2004 09 20                                                                 */
/* M. Booth                                                                   */
/* ICS4M                                                                      */
/******************************************************************************/


//
import javax.swing.JOptionPane;

public class StringSentinel
{

   public static void main( String args[] )
   {
      final String SENT = "stop";  //stops loop
      int intCounter;        // number of grade to be entered next
      String strName;  //input-name of student

      // initialization phase
      intCounter = 0;   // initialize loop counter

      // priming - prompt for input and read name from user
      strName = JOptionPane.showInputDialog(
            "Enter name or stop to end program: " );

      // repeat for each name
      while (!( strName.equals(SENT) ))  // loop until "stop"
      {
         intCounter = intCounter + 1;  // increment name counter
         // prompt for next input and read name from user
         strName = JOptionPane.showInputDialog(
            "Enter name or stop to end program: " );
      } // end while

      //check for at least 1 grade
      if (intCounter != 0)
      {

          // display number of students
          JOptionPane.showMessageDialog( null, "Number of students: "
                            + intCounter,"Class #",
                            JOptionPane.INFORMATION_MESSAGE );
      }
      else
      {
          JOptionPane.showMessageDialog( null, "No names entered",
                            "Class Average", JOptionPane.INFORMATION_MESSAGE );
      }    //end else

      System.exit( 0 );  // terminate the program

   } // end main

} // end class String Sentinel