/** This program is intended to be used with the book "Java 6 -- What Do You Want To Do?"
 * by Steven P. Warr and is distributed free of charge and without and expectations of remuneration.
 * Chapter BAS   NOTE all programs begin with the title of the chapter in which
 * they are intended to be used.   Copyright 2010 Steven P. Warr All rights reserved
 */

import java.io.*;   		// needed so you can use the File class
import java.util.*;  		//needed for Scanner
public class Bas09
{
	public static void main(String[ ] args) throws IOException
		{
		     int numItems = 0;
			 int x = 0;
             double [ ]price = new double [200];  //200 is an educated guess, but must
													//be large enough to handle any 
													//possibility.
			 File filename = new File("nameOfFile.data");  
			 Scanner inFile = new Scanner(filename);

			 while(inFile.hasNext())
					{
				          price[x] = inFile.nextDouble( );  // read one item and 
 				   			//point to the next one.
					      x ++;  // add one so there is a new index.
					}
			numItems = x;  //Count of how many items.
		    for(int c = 0;c < numItems ; c++)   // Use numItems because price.length is 200       
				System.out.println(c + ". " + String.format("%7.2f",price[c]));  

        }
}
