import java.io.*; import java.util.*; public class gradesFile { 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")); // Read first and last name into name. name = inFile.next() + " " + inFile.next(); test1 = inFile.nextInt(); test2 = inFile.nextInt(); test3 = inFile.nextInt(); // close the file inFile.close(); average = (test1 + test2 + test3) / 3.0; System.out.printf("%n%-20s%10s%10s%10s%10s%n", h1, h2, h3, h4, h5); System.out.printf("%-20s%10s%10s%10s%10s%n", u1, u2, u2, u2, u3); System.out.printf("%-20s%10d%10d%10d%10.2f%n%n", name, test1, test2, test3, average); } }