/* Check1.java CIS 111 10/31/07 David Klick This program generates a total for the data file created by Create1.java so it can be checked when the control break report is generated. */ public class Check1 extends CIS111App { public static void main(String[] args) { int month, day, year; double amt; double tot; int recs; String filename = "sales.txt"; SequentialFile filein; // clear screen and initialize variables clearConsole(); recs = 0; tot = 0.0; // open data (input) file filein = new SequentialFile(filename, FileMode.INPUT); // read in each record and sum up the amt field while (!filein.eof()) { year = filein.readInt(); month = filein.readInt(); day = filein.readInt(); amt = filein.readDouble(); recs = recs + 1; tot = tot + amt; } // display the number of records and the total amount println("There are " + recs + " records in the file"); println("The total amount is $" + formatCurrency(tot, "##,###,##0.00")); // close the input file and exit filein.close(); } }