I am having hard time completing my java lottery program. i am trying to write two public function play()and score. Play supposed to prompt the user to input $1 in the machine. Score should calculate the number of picks that match the winning number. Please help me. here is my code that is what i got so far.
Code:
import java.util.*;
public class Lottery {
//private int[] winner;
//private int[] picks;
int play;
int score;
//winner =int [5];
public static void main(String[] args) {
//Random generator and scanner
Scanner sc = new Scanner(System.in);
Random generator = new Random();
System.out.println("Enter a number between 1-35.");
int ch =sc.nextInt();
int winner = (int) (Math.random() *35) + 1;
if(ch == 10)
System.out.println("Congrast, you have won!");
else
System.out.println("Sorry, you did not have the winning number\n."
+"The winning number is " + winner + ",");
//class play{
//int paly = 0;
for(int i = 1;i < 35; i++){
Scanner diceRoller = new Scanner(System.in);
int roll = diceRoller.nextInt(5)+1;
System.out.println(roll);
}
}
}
Comment