// This file demonstrates reading data from a text file using
// the Scanner class and the File class
//
//  -- M. Branicky, 10/09/06, 10/07/07

import java.util.Scanner; // needed for input processing using Scanner
import java.io.File;      // needed for file input/output

public class ReadFile {
  public static void main(String args[]) throws Exception {  // NOTE change here

    // Open the file
    File infile = new File("MadlibData.txt");

    // attach the Scanner to the file (versus keyboard)
    // Scanner input = new Scanner( System.in );
    Scanner input = new Scanner( infile );

    // Variables to be used in the story
    double number = 0.0;
    String pluralNoun = "", adjective = "";

    // Get input from file
    while (input.hasNext()) {
      pluralNoun = input.next();
      adjective = input.next();
      number = input.nextDouble();

      // Display story
      System.out.printf("After the man ate %f %s, he felt very %s.\n",
         number, pluralNoun, adjective);
    }

    // Close the file
    input.close();
  }
}
