This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes sort and get median help Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "sort and get median help" Watch "sort and get median help" New topic
Author

sort and get median help

Duc Nguy
Greenhorn

Joined: Nov 12, 2001
Posts: 7
I created a java program that deals with array but i got stuck on sorting the number in the array and getting the median from the sort can some help me out on this one.
import sort;

public class Random
{
public static void main (String[] args)
{
double total = 0;
double average = 0;
double[] number = new double[25];
for(int i = 0; i < 25; i++)
{
number[i] = (Math.random()*100+1);
total +=number[i];
}
average = total/25;
System.out.println("Average number in array: " + average);
{
Sorts.selectionSort (number[i]);
for (int index = 0; index < grades.length; index++)
System.out.println (number[i] + " ");
}
}
}

Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
The code posted omits the bits that have to do with sorting. And what's there won't even compile with those number[i]s outside the for loop. This makes helping you very difficult...
- Peter
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: sort and get median help
 
Similar Threads
How would i break this down into seperate metods?
Help with assigning Array Size
Find min and max in ArrayList
Array and GUI
Input Validation Help