Results 1 to 7 of 7
Thread: Random numbers and arrays
- 03-21-2009, 09:56 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
Random numbers and arrays
Hi,
I'm new to writing java and am having a bit of trouble writing a program and would really appreciate some help :)
Im trying to make a program that creates an array of 20 random integers between 0 and 99, then allows the user to enter a number (N) between 0 and 99 so that it (the program) can tell the user how many of the integers are greater than or equal to N.
Everything i've tried gets an error! please help! :o
- 06-09-2009, 05:34 PM #2
Member
- Join Date
- Feb 2009
- Posts
- 29
- Rep Power
- 0
you can post your code, it will be helpfull otherwise check this example:Generate random numbers using Math.random | Java Examples - Java Program Sample Source Code
Impossible is Nothing
- 06-09-2009, 07:19 PM #3
... moving to "New to Java" subforum since no reference to NetBeans can be observed.
CJSL
Edit: Moved from the "NetBeans" subforumLast edited by CJSLMAN; 06-09-2009 at 07:21 PM. Reason: Updated to indicate that the post was moved
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 06-09-2009, 07:34 PM #4
pseudo code
Here's some pseudo code that might help:
... or somethng like that- create array (size 20)
- Ask user for number between 0 & 99
- start loop (20 loops)
- create random number between 0 & 99 (Using Random class)
- insert random number as an element into the array
- end loop
- start loop (size 20)
- if array element >= user's number then add 1 to "greaterEqual" variable
- end loop
- print "greaterEqual" variable
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 06-09-2009, 10:09 PM #5
Check out the Random class or the Math.random() method for generating the random numbers.
Also check out Arrays.
If your unsure as to how to make the loops, conditional statements, and flow of the program as well, it's probably best you start from the beginning.
Mr. Beans
- 06-09-2009, 10:23 PM #6
btw, its 3 months ago. I don't think his comming back...
USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
- 06-10-2009, 01:09 AM #7
Similar Threads
-
How do I generate random numbers in a certain range using the random class?
By frasifrasi in forum New To JavaReplies: 8Last Post: 04-19-2009, 05:50 PM -
Help with random numbers
By checkmylongboarding in forum New To JavaReplies: 2Last Post: 01-12-2009, 05:47 AM -
Random numbers
By jithan in forum Advanced JavaReplies: 3Last Post: 06-14-2008, 02:04 PM -
random numbers without random class`
By carlos123 in forum New To JavaReplies: 4Last Post: 01-17-2008, 10:44 PM -
random numbers
By carlos123 in forum New To JavaReplies: 1Last Post: 12-22-2007, 02:56 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks