//Assignment 6 import java.io.*; public class Assignment6 { public static void main (String[] args) throws IOException { final int LENGTH = 40; // total length of the one TA's name // and all blank space before // TA's allocated space BufferedReader inFile; inFile = new BufferedReader (new FileReader ("building.dat")); String name; // the String variable to store one TA's name double space; // the double variable to store // space allocated for one TA double total = 0.0; // the double variable to store // total space allocated String line; // the String variable to store information // to be printed for one TA's record // (including name and space allocated) System.out.println("Name: " + " Space (in sq. ft):"); System.out.println("----------------------------" + "--------------------------"); while ((name = inFile.readLine ()) != null) // try to read the first line for each record. // if successfully, continue to read second line. // otherwise, we have reached the end of the file // and the loop is over { space = Double.parseDouble(inFile.readLine()); // read the second line for each record // which is space allocated for one TA total = total + space; // calculate current total space line = name; for(int i = name.length(); i < LENGTH; i++) line = line + " "; line = line + space; System.out.println(line); // print out one TA's record. // the code decide the number of blank space // which should be printed between TA's name // and space record according to the length // of TA'name } System.out.println("----------------------------" + "--------------------------"); System.out.println("Total: " + " " + total); // print out the total space allocated inFile.close(); } }