Many teachers consider it a violation of academic integrity to post your code online, so you should be careful about putting your name on things and about posting exact code if that is the case with your teacher.
/*
*@author Brock Shelton
*Date: April 12,2010
*Purpose: Write a lotter class that stimulates a lottery
*/
import java.util.Scanner; //imports Scanner class
import java.util.Random; //import Random class
public class Lottery
{
private int[] lucky = new int[5];
private int win;
private Random r1;
private Random r2 = new Random();
private Random r3 = new Random();
private Random r4 = new Random();
private Random r5 = new Random();
private int num1 = r1.nextInt(10);
private int num2 = r2.nextInt(10);
private int num3 = r3.nextInt(10);
private int num4 = r4.nextInt(10);
private int num5 = r5.nextInt(10);
public Lottery()
{
r1 = new Random();
win = 0;
getNumbers();
pick(lucky);
output();
}
}
Notice how I changed your 'int win' declaration; you made a common beginner mistake. If you declare a variable inside of a method, the variable no longer exists outside of that method (and cannot be referred to outside of that method). So if you wanted to refer to your 'win' variable that you declared as "private int win" you'd just say "win = ..." or "this.win = ..." inside of a method. If you declare a variable as a class variable (for example, your r1-r5 and num1-num5 variable are all class variables) it can be used inside of any method in the class, and …