English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write a program that creates a list of ten (10) random numbers between 0 and 100, and then sorts the numbers in increasing order. To create the random numbers, assume that your program can call a static method (or function) called Random.get(lower, upper) that returns a random number in the range lower to upper.
Write your own sort method – do not call any built-in sort routine. Print the list of numbers to the console before sorting and after. Divide the task into three or more methods -- one method to create the list, another to do the sorting, and a third method to print out the list, and a main method that calls the other methods in proper order.

2006-07-10 06:20:57 · 4 answers · asked by ephity 1 in Computers & Internet Programming & Design

pls help i'm in need of this code

2006-07-10 06:29:14 · update #1

it is in java

2006-07-10 06:32:50 · update #2

4 answers

Do your own homework...

use the random.get method to generate the number... assign them to variables, or an array.... use if statements to sort...

search the internet for bubble sort

2006-07-10 06:23:11 · answer #1 · answered by Duds331 5 · 0 0

Well, since you didn't specify what language you're using, I'm going to make one up. It's called KickA Pseudo language. Feel free to submit this code to your professor.

main{
list numbers = getRandomNumbers;
sort(numbers);
print(numbers);
}

list getRandomNumbers
{
list result;
result.add(Random.get(0, 100));
result.add(Random.get(0, 100));
result.add(Random.get(0, 100));
result.add(Random.get(0, 100));
result.add(Random.get(0, 100));
result.add(Random.get(0, 100));
result.add(Random.get(0, 100));
result.add(Random.get(0, 100));
result.add(Random.get(0, 100));
result.add(Random.get(0, 100));
}

sort(list aList)
{
aList.bubbleSort;
}

print(list aList)
{
print aList[0];
print aList[1];
print aList[2];
print aList[3];
print aList[4];
print aList[5];
print aList[6];
print aList[7];
print aList[8];
print aList[9];
}

2006-07-10 13:29:04 · answer #2 · answered by Steve S 4 · 0 0

Show your work so far. I won't do it for you.

2006-07-10 13:23:58 · answer #3 · answered by lampoilman 5 · 0 0

have you heard about modulate?

2006-07-10 13:24:58 · answer #4 · answered by n9flyboy 4 · 0 0

fedest.com, questions and answers