?
Solved

Random number generator between 0 - 100

Posted on 2009-02-19
7
Medium Priority
?
1,391 Views
Last Modified: 2013-11-23
I am trying to create a number generator between 0 - 100, this my code atm:

Could someone help me out?

Cheers


private void newGame()
	{
		
		numGames = i++;
		java.util.Random rand = new java.util.Random();
		i =rand.nextInt(100+1);
		theNumber = i;
	}

Open in new window

0
Comment
Question by:LyonJay
  • 5
  • 2
7 Comments
 
LVL 26

Expert Comment

by:ksivananth
ID: 23680208
whats the issue?
0
 
LVL 3

Author Comment

by:LyonJay
ID: 23680218
it's giving me cannot find symbol?

Is it a import issue?

Regards

Lyon JT
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 23680234
which line?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Author Comment

by:LyonJay
ID: 23680239
6, 7

Regards

Lyon JT
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 23680242
post the full code of the class otherwise!
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 23680244
try

int i = rand.nextInt(100+1);
theNumber = i;
0
 
LVL 26

Accepted Solution

by:
ksivananth earned 2000 total points
ID: 23680253
or

theNumber = rand.nextInt(100+1);
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question