Hello. I am working on this and it asks for me to print a series of names in ascending order then descending order. This is what the projects asks:
Call both your project and class AscendDescend. The first column should be in ascending order and the second in
descending order. The output should appear as below (Be sure to include the headers):
Ascend Descend
Agnes Thomas
Alfred Mary
Alvin Lee
Bernard Herman
Bill Ezra
Ezra Bill
Herman Bernard
Lee Alvin
Mary Alfred
Thomas 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] + " "); } } } }
I cannot get it to print in descending order. Please send me feed back on this.