6 Replies - 3062 Views - Last Post: 17 March 2010 - 04:55 PM Rate Topic: -----

#1 Memb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-March 10

Lottery program

Posted 17 March 2010 - 11:01 AM

Hi,
I need someone to do me a lottery program. I need this program, so that I can use it for practicing java (I can watch how certain things have been done in it). I want it to be done with basic Java and I want it to be continued the same way as in this.

import java.util.Scanner; 

public class lottery {

  private static Scanner scanner = new Scanner(System.in);

  public static void main(String[] args) {

      boolean[] allNumbers = new boolean[49];
      int[] rightLine = new int[7];
      int[] additionalNumbers = new int[3];
      int[] guessingLine = new int[7];
      

        
      empty(allNumbers);


      
      for(int i=0;i<rightLine.length; i++)
        rightLine[i]= generateNumber(allNumbers);
            for(int i=0;i<additionalNumbers.length; i++)
        additionalNumbers[i]= generateNumber(allNumbers);
      
      
// for checking
      print(rightLine);
      print(additionalNumbers);
      
      
        
  }
  private static void empty(boolean[] allNumbers) {
      for(int i = 0; i<allNumbers.length; i++) {
          allNumbers[i] = false;
      }
  }

  private static int generateNumber(boolean[] allNumbers) {
      boolean new = false;
      int a;
      do {
           a = (int)(49*Math.random());
           new = allNumbers[a]==false;
        }while(!new);
      allNumbers[a] = true;
      return (a+1);
  }

  private static void print(int[] rightLine) {
      for(int i=0; i<rightLine.length;i++){
          System.out.print(rightLine[i]+ " + ");
      }
      
      System.out.println("");
      
 
  }
  }



The program:
The computer generates 7 numbers between 1 – 49 and 3 additional numbers

Winnings
7 numbers right, 1 103 958.20 USD
6 numbers right and additional number right, 28 410.60 USD
6 numbers right, 1972.40 USD
5 numbers right, 60.40 USD
4 numbers right, 13.70 USD

You can choose three types of lottery
- normal, 7 numbers, 0.80 USD
- advanced, 10 numbers, 96 USD
- expert, 15 numbers, 189.60 USD

Make a program that
a )
generates the right line
lets the player decide what numbers to choose
checks the line and lets the player continue (keeps an record of the winnings)

b )
generates the right line
lets the player decide a line for himself/herself with all three types of lottery
checks the result and keeps an record of the winnings on all the three types when playing 100 / 1000 / 10000 / 'a number given by the player' times
Tells what one should except in winnings / losings on all three lottery types and tells how many times the player has won on which type and also tells how many rounds were played without winnings
Remember to check that the same number can’t be raffled or chosen twice.

This post has been edited by Memb: 17 March 2010 - 11:04 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Lottery program

#2 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Lottery program

Posted 17 March 2010 - 11:03 AM

Well what's wrong with the code you just posted? Does it not do what you want, does it generate errors?

This isn't just a homework service where you can come to get your coding done for you
Was This Post Helpful? 0
  • +
  • -

#3 Memb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-March 10

Re: Lottery program

Posted 17 March 2010 - 11:08 AM

The code hasn't be done by me as it's just learning material. The thing is tha I'm a complete newbie in java and have no idea what to do. If someone could finish the whole thing, I could see how certain thing have been (or should be) done.
Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2965
  • View blog
  • Posts: 11,222
  • Joined: 15-July 08

Re: Lottery program

Posted 17 March 2010 - 11:14 AM

I'm sorry, but that's just not how it wok around here. We don't care who wrote it, just read rule #1 again:

Quote

We will not do your homework for you! Do not ask us to give you code!


Now if you have questions on the code you posted, please ask, but we won't do code for you.
Was This Post Helpful? 0
  • +
  • -

#5 Memb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-March 10

Re: Lottery program

Posted 17 March 2010 - 11:26 AM

Well, how should I continue? What to do next and how to do it? :)
Was This Post Helpful? 0
  • +
  • -

#6 neill.joubert   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 16-March 10

Re: Lottery program

Posted 17 March 2010 - 11:32 AM

Out of interest, what school do you go to?, because i go to St Benedict's, and i was given a lottery program to do when i started, except i only had instructions, no code. My advice would be to look up the api documents and learn how to use them first, thats what i did when i started.
Was This Post Helpful? 0
  • +
  • -

#7 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Lottery program

Posted 17 March 2010 - 04:55 PM

To generate the unique numbers here is the snippet
http://www.dreaminco...snippet2992.htm
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1