473,320 Members | 1,952 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,320 software developers and data experts.

Math.random help! please

hey im new to java and im trying to get stars to appear randomly accross the sky and i cant fugure out how to use the functions
for (a=1;a<1000;a=a+10)
{
g.fillOval(0+a,2,6,6);


}
thats what i have now and the stars go stright accross teh sky..if nothing else then i would just line the stars up in teh sky but no matter how big i make my for loop, the starts just go one line stright accross the top...
id like stars(ovals) from 0,350
Dec 3 '07 #1
3 1672
r035198x
13,262 8TB
hey im new to java and im trying to get stars to appear randomly accross the sky and i cant fugure out how to use the functions
for (a=1;a<1000;a=a+10)
{
g.fillOval(0+a,2,6,6);


}
thats what i have now and the stars go stright accross teh sky..if nothing else then i would just line the stars up in teh sky but no matter how big i make my for loop, the starts just go one line stright accross the top...
id like stars(ovals) from 0,350
Well, you haven't used Math.random in your loop at all so you shouldn't really expect to get random output.
Dec 3 '07 #2
yea i know im sorry...i was just showing you my loop with the stars goin accros the sky..i didnt use math.random beacuse i dont know how to use it..thus me asking the question
Dec 3 '07 #3
r035198x
13,262 8TB
yea i know im sorry...i was just showing you my loop with the stars goin accros the sky..i didnt use math.random beacuse i dont know how to use it..thus me asking the question
A good source of information about Java classes and their methods is the API specs. See the entry for Math.random here.
Also have a look at the specs for the java.util.Random class
Dec 3 '07 #4

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

Similar topics

2
by: Murat Tasan | last post by:
here is the situation... i have an array... and i select something from random from it. i pick a random number x by using Math.random() and multiplying it by the length of the array. but this...
5
by: R. Russell Kinter | last post by:
Hi all, First of all I am fairly new to javascript. Most of my experience has been with its subset vrmlscript, so have mercy. The following script works in I.E. 5.5, but hangs up in Netscape 4.8...
4
by: Robert Scheer | last post by:
Hi. Reading about the Math.random method I saw that by default it generates between 0 and 1. To generate numbers between a greater range I can use these syntaxes: x = Math.random()/10 x =...
23
by: Thomas Mlynarczyk | last post by:
I remember there is a programming language where you can initialize the random number generator, so that it can - if you want - give you the exactly same sequence of random numbers every time you...
6
by: RobG | last post by:
I am writing a script to move an absolutely positioned element on a page by a factor using style.top & style.left. The amount to move by is always some fraction, so I was tossing up between...
3
by: Bart Vandewoestyne | last post by:
Simple question: does the Java standard specify what random number generator algorithm should be used for Math.random() ? If 'no', then can anybody tell me what PRNG is behind Sun's version of...
8
by: babyshuyi | last post by:
Hey there guys, I was wondering if anyone could be helpful enough to help me with this. I am very new to Java.I am trying to understand how to work and use a Math.random() in my assignment where I...
9
by: Ken Fine | last post by:
Hi there, I have written a simple function that attempts to set the angle of objects so as to place them in aesthetically appealing ways. The code follows; there is some stupidness in it (e.g. a...
34
by: Johannes Baagoe | last post by:
About Math.random(), ECMA 262 just says "Returns a number value with positive sign, greater than or equal to 0 but less than 1, chosen randomly or pseudo randomly with approximately uniform...
2
by: Helmer | last post by:
i am in programming class trying to make an applet involving random placement of colored blocks, but an error is created when i try to run it saying "no method named "random" was found in type...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.