HEEEELP
im stuck in an infinite loop. Im very new to this and need help. Here is the program:
// Department.java - This program creates a report that lists transaction
// details for a department store listed by department number, total sales for
// each department, and the total sales for the store.
// Input: department.dat.
// Output: Report.
import java.io.*; // Import class for file input.
public class Department
{
public static void main(String args[]) throws Exception
{
// This is the housekeeping module() work.
// Declare variables.
String head1 = "DEPARTMENT STORE SALES";
int transNumber = 0;// Current record transaction number.
double amount = 0; // Current record transaction amount.
int deptNum = 0;// Current record department number.
String transString = "";// String version of transaction number.
String amountString = ""; // String version of transaction amount.
String deptNumString = ""; // String version of department number.
double deptTotal = 0;// Sales total for a department.
double grandTotal = 0;// Total of all sales.
int prevDept;// Previous department number.
// Open input file.
FileReader fr = new FileReader("department.dat");
// Create BufferedReader object.
BufferedReader br = new BufferedReader(fr);
// Print two blank lines.
System.out.println();
System.out.println();
// Print heading.
System.out.println(head1);
// Print two blank lines.
System.out.println();
System.out.println();
// Read first record from file.
if((transString = br.readLine()) != null) // Test for EOF.
{
amountString = br.readLine();
deptNumString = br.readLine();
// Convert Strings to integer or double.
transNumber = Integer.parseInt(transString);
amount = Double.parseDouble(amountString);
deptNum = Integer.parseInt(deptNumString);
}
// Assign department number to previous department number.
prevDept = deptNum;
// Check for EOF.
while(transString != null)
{
// Test control break variable here.
if(deptNum != prevDept)
{
// Perform control break work here.
System.out.println(" Department Number: " + prevDept);
}
// Print transaction number and transaction amount here.
System.out.println(transNumber + " Transaction Amount: " + amount);
// Add transaction amount to department total here.
deptTotal += amount;
}
// Read next record here.
if((deptNumString = br.readLine()) != null)
transString= br.readLine();
// This is the cleanUp() module work.
System.out.println("Department Number: " + prevDept);
System.out.println();
System.out.println();
// Print department number and department total here.
System.out.println(deptTotal + "Department Total: " + deptTotal);
// Add department total to grand total here.
grandTotal += deptTotal;
prevDept = deptNum;
deptTotal = 0;
// Print total sales here.
System.out.println("Total Sales: " + grandTotal);
// Close file.
br.close();
// Exit program.
System.exit(0);
} // End of main() method.
} // End of Department class.
[3390 byte] By [
DamRatza] at [2007-10-2 4:23:36]

Well I cant seem to figure out what it is that needs to be done. I still stuck on it. What should I change?// Department.java - This program creates a report that lists transaction
// details for a department store listed by department number, total sales for
// each department, and the total sales for the store.
// Input: department.dat.
// Output: Report.
import java.io.*; // Import class for file input.
public class Department
{
public static void main(String args[]) throws Exception
{
// This is the housekeeping module() work.
// Declare variables.
String head1 = "DEPARTMENT STORE SALES";
int transNumber = 0;// Current record transaction number.
double amount = 0; // Current record transaction amount.
int deptNum = 0;// Current record department number.
String transString = "";// String version of transaction number.
String amountString = ""; // String version of transaction amount.
String deptNumString = ""; // String version of department number.
double deptTotal = 0;// Sales total for a department.
double grandTotal = 0;// Total of all sales.
int prevDept;// Previous department number.
// Open input file.
FileReader fr = new FileReader("department.dat");
// Create BufferedReader object.
BufferedReader br = new BufferedReader(fr);
// Print two blank lines.
System.out.println();
System.out.println();
// Print heading.
System.out.println(head1);
// Print two blank lines.
System.out.println();
System.out.println();
// Read first record from file.
if((transString = br.readLine()) != null) // Test for EOF.
{
amountString = br.readLine();
deptNumString = br.readLine();
// Convert Strings to integer or double.
transNumber = Integer.parseInt(transString);
amount = Double.parseDouble(amountString);
deptNum = Integer.parseInt(deptNumString);
}
// Assign department number to previous department number.
prevDept = deptNum;
// Check for EOF.
while(transString != null)
{
// Test control break variable here.
if(deptNum != prevDept)
{
// Perform control break work here.
System.out.println(" Department Number: " + prevDept);
}
// Print transaction number and transaction amount here.
System.out.println(transNumber + " Transaction Amount: " + amount);
// Add transaction amount to department total here.
deptTotal += amount;
}
// Read next record here. Im not sure how to get the next record to read from this point.
if((deptNumString = br.readLine()) != null)
transString = br.readLine();
// This is the cleanUp() module work.
System.out.println("Department Number: " + prevDept);
System.out.println();
System.out.println();
// Print department number and department totalhere.
System.out.println(deptTotal + "Department Total: " + deptTotal);
// Add department total to grand total here. down here do I need to zero out the amount variable too?
grandTotal += deptTotal;
prevDept = deptNum;
deptTotal = 0;
// Print total sales here.
System.out.println("Total Sales: " + grandTotal);
// Close file.
br.close();
// Exit program.
System.exit(0);
} // End of main() method.
} // End of Department class.