Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

random class...

Name: Anonymous 2006-11-07 1:10

guys im trying to create a simulation of the lottery using java... i am makin an array consisting of 5 random numbers ranging from 0 to 9 the thing is i can only get the amount of arrays the class has and everytime i run the application all i get for the 5 random numbers are a bunch of zeros.

this is my code so far...

import java.util.Scanner;
import java.util.Random;
public class Lottery
{
    public static void main (String[] args)
    {
            int[] lotteryNumbers = new int[5];
            int indx;
        int num1, num2, num3, num4, num5;
        Random rand = new Random();
        int sum = 0;
            Scanner key = new Scanner(System.in);
       
        System.out.println("The array size is " +                          lotteryNumbers.length);
        for (indx = 0; indx <5; indx++)
        {
       
                num1 = rand.nextInt(9);
            num2 = rand.nextInt(9);
            num3 = rand.nextInt(9);
            num4 = rand.nextInt(9);
            num5 = rand.nextInt(9);
           
           
            System.out.println(lotteryNumbers[indx]);
          
        }

i forgot to mention the user also has to input his own 5 numbers to see if he won the "grand prize". but i think i have that part down for now... all i am really interested in are those damn 5 random numbers which i cant seem to get right... any help would be appreciated.

Name: Anonymous 2006-11-13 19:59

>>1
Stop saying "create". That's asinine. It's like saying "get" when you mean "procure", or "take", or "become". The proper word in this instance is "write", as in programs or articles or books or fucking world4ch comments.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List