Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
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 05-31-2007, 05:08 PM
Member
 
Join Date: May 2007
Posts: 11
Hasan is on a distinguished road
Finding Median of X Integers
I need to find the median of 5 integers for a program. Currently i am sorting the numbers using Math.min and Math.max. If someone has a slightly more elegant way please post here.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-31-2007, 05:12 PM
Member
 
Join Date: May 2007
Posts: 10
Valeriano is on a distinguished road
You should use an array and take a look at Arrays.sort(). This is one way of doing it, if-else and ternary are no good. If this is an assignment then you should look to deliver code that will work for any number of values even if your assignment works only with five numbers, the same algorithm should work with any amount.

Arrays (Java 2 Platform SE 5.0)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-12-2008, 02:48 PM
Member
 
Join Date: Aug 2008
Posts: 11
g25451 is on a distinguished road
how are you?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-12-2008, 03:06 PM
Senior Member
 
Join Date: Jun 2008
Posts: 194
Fubarable is on a distinguished road
Abuse reported on g25451 for spamming the forums.
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
[SOLVED] Integers (averages and remainders)...need help Zebra New To Java 4 04-16-2008 02:26 PM
Quick sort with median-of-three partitioning Java Tip Algorithms 0 04-15-2008 08:40 PM
Reading Integers from a text file tress New To Java 3 04-03-2008 04:48 AM
Random Integers www.kwalski.com Java Applets 8 12-09-2007 06:49 PM
Convert roman numerals to integers Felissa Advanced Java 2 07-02-2007 12:27 AM


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


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