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.
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.
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.