Results 1 to 7 of 7
Thread: need help, weird question kinda.
- 01-14-2008, 03:15 AM #1
Member
- Join Date
- Nov 2007
- Posts
- 38
- Rep Power
- 0
- 01-14-2008, 03:34 AM #2
What have you got so far? (please remember to use code tags)
Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
- 01-14-2008, 03:38 AM #3
Member
- Join Date
- Nov 2007
- Posts
- 38
- Rep Power
- 0
well i know how to get the time.
int sec = cal.get(Calendar.SECOND);
- 01-14-2008, 03:52 AM #4
Fair enough, so there's 60 seconds in a minute, right? You have a variable that represents the current seconds', take that value and divide it by three and use I believe Math.round() -> or something to that effect, I'm not sure of the exact use but there is one in the API. If you divide 60 by 3 that result has to be 20 or less by the operation rule you performed. For example, if (sec == 42) and (42 / 3) = 14 finally, 14 < 20.
Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
- 01-14-2008, 04:07 AM #5
Member
- Join Date
- Nov 2007
- Posts
- 38
- Rep Power
- 0
ok now i need to put this through an equation that makes it psuedorandom because my assignment is to generate 10,000 numbers 1-20, i got the seed, now i need help with an equation to put it through to keep it 1-20, any suggestions?int sec = cal.get(Calendar.SECOND);
int sec2 = sec / 3;
int sec3 = Math.round(sec2);
- 01-17-2008, 10:45 PM #6
Member
- Join Date
- Nov 2007
- Posts
- 38
- Rep Power
- 0
eh, any suggestions? ^^
- 01-22-2008, 03:19 AM #7
well you could use a while loop until the number is between 20.
Now, it does the process until the final number is between 1 and 20.Java Code:boolean done = false; while(!done) { int sec = cal.get(Calendar.SECOND); int sec2 = sec / 3; int sec3 = Math.round(sec2); if(sec3 >= 1 && sec3 <= 20) done = true; }
Does this help?
Similar Threads
-
Question mark colon operator question
By orchid in forum Advanced JavaReplies: 9Last Post: 12-19-2010, 08:49 AM -
JSP Question
By maheshkumarjava in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 03-29-2008, 10:51 AM -
Weird data output
By Shaolin in forum New To JavaReplies: 12Last Post: 12-11-2007, 04:27 PM -
weird looking shape JButton is it possible?
By unhurt in forum AWT / SwingReplies: 8Last Post: 11-03-2007, 09:10 AM -
k this is my ultimate project. kinda
By jason27131 in forum New To JavaReplies: 2Last Post: 08-03-2007, 04:47 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks