Question: import java.util.Scanner; public class array5j { public static void main(String[] args) { int a[] = new int[10]; // declares array a with 10 cells int

import java.util.Scanner; public class array5j { public static void main(String[] args) { int a[] = new int[10]; // declares array a with 10 cells int size = 7; // this is number of elements we'll have in the array a.

InputArray(a,size);

System.out.println("the sorted array is:"); int sorted[] = new int[10]; sorted = BubbleSort(a,size); OutputArray(sorted,size);

} // end of main program

public static void InputArray(int x[], int size) { Scanner input = new Scanner(System.in); int i; System.out.println ( "Enter " + size + "data: "); for (i=0; i

public static void OutputArray(String x[], int size) { System.out.println("The array is:"); for (int i=0; i x[i+1]) { int temp=x[i]; x[i]=x[i+1]; x[i+1]=temp; }; }; }; return x; };

public static int[] reverse(int[] x, int size) { String[] result = new String[x.length];

for (int i=0; i<=size-1; i++){ result[i] = x[size-i-1]; } return result; } }

Use this program and change it so that it will take a String array and sort it in anti-alphabetical order. Use compareTo or compareToIgnoreCase for the String type. Ex. input: dog lazy the output: the lazy dog

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!