Hello. I am working on this project and it asks me to make two columns of words that are ascending in one column and descending in the other. This is the Project:
Call both your project and class AscendDescend. The first column should be in ascending order and the second indescending order. The output should appear as below (Be sure to include the headers):
Ascend
Agnes
Alfred
Alvin
Bernard
Bill
Ezra
Herman
Lee
Mary
Thomas
Descend
Thomas
Mary
Lee
Herman
Ezra
Bill
Bernard
Alvin
Alfred
Agnes
This is my code so far:
import java.util.*;
public class twoforone
{
public static void main(String args[])
{
String theArray[] = {"Bill", "Mary", "Lee", "Agnes", "Alfred", "Thomas", "Alvin", "Bernard", "Ezra", "Herman"};
for(int j = 0; j < theArray.length; j++)
{
Arrays.sort(theArray);
System.out.println(theArray[j] + " ");
}
System.out.println(" ");
{
for(int m = 0; m < theArray.length; m++)
{
Arrays.sort(theArray);
System.out.println(theArray[m] + " ");
}
}
}
}
Please send me some feedback on this. I need help with the descending column. I dont know the code to descend. Please help.