/* 9/25/2019 * * (2) introduce input files * Must put the following 2 things: * (a) import the java.io pkg * (b) put "throws IOException" * for input files, use 2 classes * File and Scanner */ import java.util.Scanner; import java.io.*; public class ReadGrades { /** main reads in a number of grades from an input file */ public static void main(String[] args) throws IOException { // create a File object File infile = new File("testScores.txt"); // create a Scanner object and connect it to the File object Scanner dataFile = new Scanner(infile); // now we can use all the methods of the Scanner class int grade; while (dataFile.hasNextInt()) { grade = dataFile.nextInt(); System.out.println("grade read in: " + grade); } } } /** Lab 8 * Write a loop to calculate a variable raised to the power of another variable. * We did 2^7 on the board and you will generalize to read in both * the base and the exponent. * * do it twice, using while and for */ /** time permitting: modify above program to count the * number of grades read in from the file */