How can I generate a certain amount of random numbers in java.?
-
I'm trying to write a program where the user enters a number and the program will generate that many random numbers. For example the user enters 5 and the program shows 1,9,5,7,6. I have so far: Scanner input = new Scanner(System.in); System.out.print("Enter n: "); int n = input.nextInt(); *****This is where I'm stuck because I'm not sure how to use whatever number the user enters and have the program generate that many random numbers. If you could help me out that would be great and if you could explain I would appreciate it. There's another part to this program but I'm pretty sure I know how to write it.
-
Answer:
use a "for" loop. in each loop, generate a random number, and display it to the screen. gl.
Jay-R R at Yahoo! Answers Visit the source
Other answers
use do while loop
Karthik Kumar Musalay
Related Q & A:
- How can I make a Spinner only by java?Best solution by stackoverflow.com
- How can I mount a network drive in Mac OS X in Java?Best solution by Stack Overflow
- How can I make my own blog about random things?Best solution by Yahoo! Answers
- How can I get a certain font onto my MSN?Best solution by Yahoo! Answers
- How can I allow only certain email addresses?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.