TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Random number genrator program in Java
Alagunila Meganathan
Aug 02
2016
Code
540
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
Randomnumbergenrator
public
class
Randomnumbergenrator {
static
final
int
first =
830844
;
static
final
int
second =
39048
;
static
final
int
third =
3840938
;
long
randomnumber =
1
;
public
Randomnumbergenrator(
long
randomnumber) {
this
.randomnumber = randomnumber;
}
public
float
randomFloat() {
randomnumber = (randomnumber * second + third) % first;
return
(
float
)randomnumber/(
float
)first;
}
public
int
randomInt(
int
max) {
return
Math.round(max * randomFloat());
}
}
Java
Random numbers