|
|
Hey all you super7 junkies out there!
This is the one for you! This program will randomly generate the numbers for a Super7 lottery ticket
and sort them in assending order. Each board for this lottery displays 7 random integers between 1 and 49.
Good Luck!
/**Name of Program File: Super7.java
Author: Travis McGrath
INFO140 Section # 04 Date: Nov. 1, 2001
Your Company Name: Lottery Predictors
Description: This program will randomly generate the numbers for a Super7
lottery ticket. Each board for this lottery displays 7 random
integers between 1 and 49*/
public class Super7
{
public static void main(String[] args)
{
System.out.print("This program will randomly generate the numbers " +
"for a Super7 lottery ticket.");
System.out.println("\n");
System.out.print("The numbers for your Super7 ticket are: ");
System.out.println();
int[] boardArray = new int[7];
for(int i = 0; i < 3; i++)
{
for (int j = 0; j <= 6 ; j++)
{
boardArray[j] = (int)((Math.random()*49)+1);
}//end array loading for
//sort loops
for (int outerIndex=1; outerIndex < boardArray.length-1; outerIndex++)
{
for (int index = 0; index < boardArray.length-1; index++)
{
if (boardArray[index] > boardArray[index+1])
{
int holder = boardArray[index];
boardArray[index] = boardArray[index+1];
boardArray[index+1] = holder;
}//end if
}//end inner loop for
}//end outer for
//print for loop
for (int boardIndex = 0; boardIndex < boardArray.length-1; boardIndex++)
{
System.out.print(boardArray[boardIndex] + "\t");
}//end print for
System.out.println();
}//end for
}//end main
}//end class
|