/* * Main.java * * Created on July 25, 2006, 2:18 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ //package javaapplication7; /** * * @author webster */ import java.io.*; import java.util.Scanner; public class Main { /** Creates a new instance of Main */ public Main() { } /** * @param args the command line arguments */ public static void main(String[] args) throws IOException{ Scanner reader; double number, sum = 0; int count = 0; reader = new Scanner(new File("numbers.txt")); while (reader.hasNext()) { number = reader.nextDouble(); System.out.println("The number is " + number); sum += number; count++; } if (count == 0) System.out.println("The file had no numbers"); else System.out.println("The average of " + count + " numbers is " + sum / count); } }