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 );
        }
    }}

Edited 4 Years Ago by ippo

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

Edited 4 Years Ago by ippo

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.

This question has already been answered. Start a new discussion instead.