import java.io.*; import java.util.*; public class gradesReport { public static void main(String[] args) throws FileNotFoundException { String h1="Name", h2="Test 1", h3="Test 2", h4="Test 3", h5="Average"; String u1="----", u2="------", u3="-------"; String name; int test1, test2, test3; double average; Scanner inFile = new Scanner( new FileReader("gradesFile.data")); PrintWriter outFile = new PrintWriter("gradesFile.report"); // Read first and last name into name. name = inFile.next() + " " + inFile.next(); test1 = inFile.nextInt(); test2 = inFile.nextInt(); test3 = inFile.nextInt(); average = (test1 + test2 + test3) / 3.0; outFile.printf("%n%-20s%10s%10s%10s%10s%n", h1, h2, h3, h4, h5); outFile.printf("%-20s%10s%10s%10s%10s%n", u1, u2, u2, u2, u3); outFile.printf("%-20s%10d%10d%10d%10.2f%n%n", name, test1, test2, test3, average); // close the files inFile.close(); outFile.close(); } }