hello sir i would like your help on how to get the median of sorted values.for example my inputs are from 1 to 9 and id like to know the java program of this one,,thank you for your help sir.
id like to know the java program of this one
We do not do people's homework for them. Try to write it yourself. If you get stuck post what you have done so far and explain what help you need.
I won't write your code, because like others have said, iy is not our place to do your homework for you.
I will, however, give you some psedocode to point you in the right direction. I believe that it is the goal of a forum such as this to provide help to people learning how to code. Psuedocode will tell you what to do, but not how to do it. That will require a little research on your part.
I will start with the assumption that you have an array of integers, and that they are pre-sorted.
Find the length of the array If the length of the array / 2 leaves a remainder of 1 get the contents of index [(length + 1) / 2] else get the contents of index [length / 2] get the contents of index [(length / 2) + 1] add the two numbers together divide the result by 2 using floating point division Display the result
You need to research how to find the length of an array in Java
You need to research how to do floating point division vs. integer division
You need to research the best type of variable to store your answer in
You need to research how to display data using one of Java's print methods