454,651 Members | 1,368 Online
Need help? Post your question and get tips & solutions from a community of 454,651 IT Pros & Developers. It's quick & easy.

# need help with my code

 P: 1 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. Expand|Select|Wrap|Line Numbers 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);   }     }   } Feb 19 '12 #1

play and score are methods but you haven't defined them as such:

Expand|Select|Wrap|Line Numbers
1. import java.util.Scanner;
2.
3. public class Lottery {
4.     public void play() {
5.         //your code goes here
6.     Scanner sc = new Scanner(System.in);
7.     }
8.
9.     public void score() {
10.          //your code goes here
11.
12.     }
13.
14.     public static void main(String[] args) {
15.     new Lottery().play();
16.
17.     }
18. }