473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Doing a Lottery program (or trying 2) [Need help!!]

Hey, I'm quite new in programing so need some help with this lottery program I'm making. What I'm trying to do is very simple, simulate a lottery but my effords are in vain since when I'm compiling it, it says that there are 100 errors ... -.- The code is right here:

class lottery {

public static void main (Strings [] args){

int ball1;
int ball2;
int ball3;
int ball4;
int ball5;
int star1;
int star2;

ball1 <= 50 && ball1 > 0;
ball2 <= 50 && ball2 > 0;
ball3 <= 50 && ball3 > 0;
ball4 <= 50 && ball4 > 0;
ball5 <= 50 && ball5 > 0;
star1 <= 50 && star1 > 0;
star2 <= 50 && star2 > 0;

System.out.println("The Lottery has Begun!!");
System.out.println("And The Numbers are:");
System.out.println(ball1 + "for the number one");
System.out.println(ball2 + "for the number two");
System.out.println(ball3 + "for the number three");
System.out.println(ball4 + "for the number four");
System.out.println(ball5 + "for the number five");
System.out.println("Now The Stars Are:");
System.out.println(star1 + "for the star number one");
System.out.println(star2 + "for the star number two");
}
}


Hope you can answer and help me with this!
Thanks a lot, ImortalSorrow
Feb 8 '08 #1
8 2387
BigDaddyLH
1,216 Expert 1GB
This lines is not a Java statement:

Expand|Select|Wrap|Line Numbers
  1. ball1 <= 50 && ball1 > 0;
What were you trying to do? What where you trying to express?
Feb 8 '08 #2
I'm trying to simulate a lottery, like some random number between 1 and 50 for five balls and between 1 and 9 for other two. just like euromilions.
Feb 8 '08 #3
Laharl
849 Expert 512MB
Those statements involving ranges for the ball's value have no meaning. To generate random numbers, use the Math.random() function (or the Random class). Math.random() returns a decimal between 0 and 1, so then you multiply by the range you want and cast to int.

Expand|Select|Wrap|Line Numbers
  1. int a = (int)(Math.random()*r) //Add 1 if you want to avoid getting 0
  2.  
Feb 8 '08 #4
BigDaddyLH
1,216 Expert 1GB
Those statements involving ranges for the ball's value have no meaning. To generate random numbers, use the Math.random() function (or the Random class). Math.random() returns a decimal between 0 and 1, so then you multiply by the range you want and cast to int.

Expand|Select|Wrap|Line Numbers
  1. int a = (int)(Math.random()*r) //Add 1 if you want to avoid getting 0
  2.  
Class java.util.Random is a little easier and clearer to use -- less arithmetic: http://java.sun.com/javase/6/docs/ap...il/Random.html
Feb 8 '08 #5
ohh ok thanks, so in this case i do:

Expand|Select|Wrap|Line Numbers
  1.  ball1 = (Math.random()1*50) 
?

srry about all these questions =P
Feb 8 '08 #6
BigDaddyLH
1,216 Expert 1GB
ohh ok thanks, so in this case i do:

Expand|Select|Wrap|Line Numbers
  1.  ball1 = (Math.random()1*50) 
?

srry about all these questions =P
What I suggest you do is write a tiny program just to learn how to generate random numbers. When you've learned how, apply that knowledge to your assignment. That's a strategy you should apply widely.
Feb 8 '08 #7
yes i guess you'r right

thank you very much for your time and help!
Feb 8 '08 #8
BigDaddyLH
1,216 Expert 1GB
Good luck on your program!!
Feb 9 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jung Joon Park | last post by:
Hi everyone. I am JJ Park. I got some questions in C++. First of all, my English is not perfect, because I am foreigner. I have got C++ code, which have no syntex error in Visual C++ ver6.0...
6
by: Rafael | last post by:
Hi Everyone, I need some help with my calculator program. I need my program to do 2 arguments and a 3rd, but the 3rd with different operators. Any help would be great. Here is my code.... ...
0
by: David | last post by:
I have a problem that just cropped up with using an ImageList in my project I am using VB .NET 200 Problem: I have existing Form with 2 Image List controls. ImageList16 (for 16x16 Images) and...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
0
by: custom | last post by:
First off, I don't know very much about programming. My problem is, I have a lottery program written in 1989, and I need minor changes made to it so I can use it. I did find the Borland name, but...
3
Chrisjc
by: Chrisjc | last post by:
I am not good at VB and I am taking a class for it at ITT... I am doing a program chanllenge and really really need help it is due today... and I am not good at this at all... could some one please...
3
by: mandogon | last post by:
Ok i have been looking at this block of code for about 2 weeks and cant figure out why my program keep on crashing within this block of code if you could help thanks void __fastcall...
30
by: carlos123 | last post by:
Ok I am working on a Hall Pass program for my computer programming class. There are 3 things that I am confused on. 1. Reading a file. 2. Taking that data read from the file and putting it into...
5
by: alck1234 | last post by:
Hi, I need help on my mini project on object orientated programming. The question goes like this: A mini-mart has just installed a bar code reader to improve efficiency at their checkouts....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.