So I'm trying to make a lottery program which outputs up to 6 sets of 6 random numbers using only 2d arrays and arrays for my project. No arraylists are allowed. Here is what i have so far, but it's not running because I don't have a main file?. Someone help. Thank you

import java.util.*;
public class EXCLotto {

    public static int[][] generateLottoTickets( int number )
    {
        int row, column;
        int [][] ticketArray = new int[number][6];
        java.util.Random random = new java.util.Random();
        for( row = 0; row < number; row++ )
        {
            for( column = 0; column < 6; column++ )
            {
                ticketArray[row][column] = random.nextInt( 49 );
            }
        }
        return ticketArray;
    }
    public static void printTickets( int[][] ticketArray, int number )
    {
        int row, column;
        String rowString;
        System.out.println( "your tickets are:" );
        for( row = 0; row < number; row++ )
        {
            rowString = "";
            for( column = 0; column < 6; column++ )
            {
                rowString = rowString + ticketArray[row][column] + " ";
            }
            System.out.println( rowString );
        }
    }}

What seems to be the problem?

I copied the code and it runs.

it says exception in thread : main
and selection doesn't contain a main type

import java.util.*;
public class EXCLotto {

    public static int[][] generateLottoTickets( int number )
    {
        int row, column;
        int [][] ticketArray = new int[number][6];
        java.util.Random random = new java.util.Random();
        for( row = 0; row < number; row++ )
        {
            for( column = 0; column < 6; column++ )
            {
                ticketArray[row][column] = random.nextInt( 49 );
            }
        }
        return ticketArray;
    }
    public static void printTickets( int[][] ticketArray, int number )
    {
        int row, column;
        String rowString;
        System.out.println( "your tickets are:" );
        for( row = 0; row < number; row++ )
        {
            rowString = "";
            for( column = 0; column < 6; column++ )
            {
                rowString = rowString + ticketArray[row][column] + " ";
            }
            System.out.println( rowString );
        }
    }

    public static void main(String args[]){
        EXCLotto.printTickets(EXCLotto.generateLottoTickets(3), 3);
    }
}

You do have a main right? This is the code that I copied. Try it and compare.

doh! thanks hehe..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.