// 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 ReadFileTrial {
  public static void main(String args[]) throws Exception {  // NOTE change here

    // Open the file
    File infile = new File("MadlibDataTrial.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
    // System.out.print("Enter a plural noun and press <ENTER>: ");
    pluralNoun = input.nextLine();
    // System.out.print("Enter an adjective and press <ENTER>: ");
    adjective = input.nextLine();
    // System.out.print("Enter a number and press <ENTER>: ");
    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();
  }
}
