import java.util.ArrayList;
import java.util.Scanner;

public class lotto {

    public static void main(String[] args) {
        String fileName = "lotto.txt";
        final int arraySize = 45;
        int[] count = new int[arraySize];

        File inputFile = new File(fileName);

        // Initialize the count array;
        for (int i = 0; i < arraySize; i++) {
            count[i] = 0;

        // Read the file
        try {
            Scanner input = new Scanner(inputFile);
            while (input.hasNextInt()) {
                int number = input.nextInt();
                //count[number] = count[number] + 1;

        } catch (FileNotFoundException e) {
            System.err.println("*** ERROR *** Could not open file " + fileName);
        printCounts(count, arraySize);


    public static void printCounts(int[] list, int n) {
        for (int i = 1; i < n; i++) {
            System.out.println("[" + i + "] " + list[i]);


Write a program that reads the lottery numbers and tabulates how many times each number was selected.  The frequency counts must be stored in an array with at least 44 positions.  (hint: it might be easier to just create an array with 45 positions in it and then ignore the [0] value).
When the program has tabulated the numbers print out the following information.
•   The number or numbers that were picked least frequently.
•   The average number of times that all of the numbers were picked.  For example, the average might have been 210 times.
•   The number or numbers that were picked the average number of times.
•   The number or numbers that were picked most frequently
Note that in the above there may be more than one number that meets the requirement.  For example, there might be just one number that has been picked 200 times, but it is possible that there was more than one that was picked that many times.
When you have reported the above data, your program should print out the frequency for each number.  For example, 
[1] 220
[2] 222
[3] 214
Your program only needs one array.  You should have a method to print the entire array.  You should also have a method to read and tabulate the array.  This means that the method should have the try...catch block within it.  

don't just copy paste your assignment here.
work on it, part by part, and at least try. you're not even bothering to mention which parts you are having trouble with, you just copied your original baseline code and assignment.

go step by step, and when you run into something you can't solve, just post a specific question with the relevant code here.

This article has been dead for over six months. Start a new discussion instead.