Everything looks good except for the sorting code:
for(sort = 0; sort < 10; sort++)
{
for(unsort = 0; unsort < 10; unsort++)
{
if(input[unsort] > Largest)
{
Largest = input[unsort];
i = unsort;
}
}
It seems to me that you are trying to use Selection Sort. Selection Sort works by finding the max and putting it at the end. Finding the second max and putting it and the second last slot and so on. Since you must write it in descending and ascending it is easier to use bubble sort (you'll see why). The following code sorts ascending.
boolean sorted=false;
//while not sorted repeat
while(!sorted)
{
//assume its sorted
sorted = true;
//make a pass thru the array
for(int i =0; i < 9; i++)
{
//get two consecutive slots
int first = input[i];
int second = input[i+1];
//if out of order, swap
if(first > second)
{
input[i+1] = first;
input[i]= second;
//KNOW ITS NOT SORTED!! so mark it as not sorted
sorted = false;
}
}
}
To sort descending, swap > with <. THATS IT!
For more programming help, visit
www.NeedProgrammingHelp.com or email me at
NeedProgrammingHelp@hotmail.com
Alex.