Reading and Writing Text Files

Write a program that will read in a file of student academic credit data and create a list of students on academic warning. The list of students on warning will be written to a file. Each line of the input file will contain the student name (a single String with no spaces), the number of semester hours earned (an integer), the total quality points earned (type double). The following shows part of a typical data file:

     Smith 27  83.7
     Jones 21  28.35
     Walker 96 182.4
     Doe 60 150

The program should compute the GPA (grade point or quality point average) for each student (the total quality points divided by the number of semester hours) then write the student information to the output file if that student should be put on academic warning. A student will be on warning if he/she has a GPA less than 1.5 for students with fewer than 30 semester hours credit, 1.75 for students with fewer than 60 semester hours credit, and 2.0 for all other students. The file Warning.java contains a skeleton of the program. Do the following:

  1. Set up the input file stream and the output filestream inside the try clause (see the comments in the program). Use inFile as the name of the BufferedReader and outFile as the name of the PrintWriter. Note that the file names are already given in String objects.
  2. Inside the while loop add a try clause to parse the input -- to get the number of credit hours (store in the creditHrs variable) and the number of quality points (store in the qualityPts variable). Compute the GPA and for those students who are on academic warning write the name, credit hours, and GPA to the output file.
  3. After the loop close both file stream objects.
  4. Test the program. Test data is in the file students.dat.