Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-14-2008, 05:15 AM
Member
 
Join Date: Nov 2007
Posts: 38
carlos123 is on a distinguished road
need help, weird question kinda.
basicly what i need is some code that takes the current time, and gets the seconds and divides it by 3 and rounds it so its a whole number between 1-20
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-14-2008, 05:34 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
What have you got so far? (please remember to use code tags)
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-14-2008, 05:38 AM
Member
 
Join Date: Nov 2007
Posts: 38
carlos123 is on a distinguished road
well i know how to get the time.

Quote:
int sec = cal.get(Calendar.SECOND);
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-14-2008, 05:52 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-14-2008, 06:07 AM
Member
 
Join Date: Nov 2007
Posts: 38
carlos123 is on a distinguished road
Quote:
int sec = cal.get(Calendar.SECOND);
int sec2 = sec / 3;
int sec3 = Math.round(sec2);
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?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-18-2008, 12:45 AM
Member
 
Join Date: Nov 2007
Posts: 38
carlos123 is on a distinguished road
eh, any suggestions? ^^
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 01-22-2008, 05:19 AM
gibsonrocker800's Avatar
Senior Member
 
Join Date: Nov 2007
Location: New York
Posts: 143
gibsonrocker800 is on a distinguished road
Send a message via AIM to gibsonrocker800
well you could use a while loop until the number is between 20.

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; }
Now, it does the process until the final number is between 1 and 20.

Does this help?
__________________
//Haha javac, can't see me now, can ya?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question mark colon operator question orchid Advanced Java 4 11-12-2008 10:08 AM
JSP Question maheshkumarjava JavaServer Pages (JSP) and JSTL 1 03-29-2008 12:51 PM
Weird data output Shaolin New To Java 12 12-11-2007 06:27 PM
weird looking shape JButton is it possible? unhurt AWT / Swing 8 11-03-2007 11:10 AM
k this is my ultimate project. kinda jason27131 New To Java 2 08-03-2007 06:47 AM


All times are GMT +3. The time now is 02:02 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org