// CSC108 Tutorial 2 Example
// Name:  Iam Me         Student ID: 555555555
// Tutor: Andria Hunter  Prof: Steve Bellantoni
//
// Program Description: This program reads in pairs of student
//     names and ID numbers.  It prints out each pair that it
//     reads.  The program exits as soon as the word "exit" is
//     entered for the student's name.

import java.io.*;

public class GetInfo {

   // Main method to add numbers and display result.

   public static void main (String[] args) throws IOException {

      // Declare 'in' so data can be read from input.
      DataInputStream in = new DataInputStream (System.in);

      // Constant to indicate when the program stops
      final String STOPPER = "exit";

      // Read in first student name before the loop
      System.out.println ("Student's name? ");
      String name = in.readLine();
      
      // Loop for each pair of student name and number.  Stop
      // looping when the STOPPER is encountered.

      while (!name.equals(STOPPER)) {
         // Read student number as an integer
         int number = Integer.parseInt (in.readLine());

         // Report information entered
         System.out.println (name + " has id " + number);

         // Get next student's name
         System.out.println ("Student's name? ");
         name = in.readLine();
      }

      System.out.println ("\nEnd of Program (exit detected)");
   }
}

