Students.java


Below is the syntax highlighted version of Students.java.


/***********************************************************************
 *  Compilation:  javac Students.java
 *  Execution:    java Students < students.txt
 *  Dependencies: StdIn.java StdOut.java
 *    data file http://www.cs.princeton.edu/introcs/15inout/students.txt
 *
 *  Reads in the integer N from standard input, then a list
 *  of N student records, where each record consists of four
 *  fields, separated by whitespace:
 *      - first name
 *      - last name
 *      - email address
 *      - which section they're in
 *  Then, print a list of email address of students in sections 4 and 5.
 *  (Booksite Web Exercise 1.5.31)
 *
 *  % 130
 *  Sarah Wang twang 7
 *  Austin Taylor actaylor 1
 *  David Rosner drosner 4
 *  Rebecca Allen rebeccaa 7
 *  Rajiv Ayyangar ayyangar 7
 *  Daniel Barrett drbarret 8
 *  Nic Byrd nbyrd 7
 *  Emily Capra ecapra 8
 *  Johnny Clore jclore 7
 *  ...
 *
 * % Section 4
 *  ---------
 *  drosner
 *  jcharles
 *  jph
 *  mlampert
 *  ...
 *
 *  Section 5
 *  ---------
 *  giwank
 *  agrozdan
 *  ajh
 *  akornell
 *  ...
 *
 *
 ***********************************************************************/

public class Students {
    public static void main(String[] args) { 

        // read the number of students
        int N = ______________________________

        // declare and initialize four parallel arrays
        String[] first   = new String[N];
        ________ last    = ____________________
        String[] _______ = ____________________
        int[] section    = ____________________

        // read in the data from standard input
        for (_______________; ____________________;  __________) {
            first[___]   = StdIn.readString();
            last[___]    = _________________________
            email[___]   = _________________________
            section[___] = _________________________
        }

        // print email addresses of all students in section 4
        StdOut.println("Section 4");
        StdOut.println("---------");
        for (int i = 0; i < N; i++) {
            if (________________________________) {
                StdOut.println(_____________);
            }
        }
        StdOut.println();

        // print email addresses of all students in section 5
        StdOut.println("Section 5");
        StdOut.println("---------");
        for (        





   }        
}