Answer to Question #187061 in Java | JSP | JSF for mansoor

Question #187061

Write a class named Sorting with sort function in order to sort the following array as program. Call sort function in main function. [4 marks]

 

                      char[] j= {'r', 'g', 'o', 'm', 'r', 'p','a'};

             

output display as “program” 


    


1
Expert's answer
2021-04-30T06:57:16-0400
public class Sorting {
	public void sort(char[] array) {
		System.out.print(array[5]);
		System.out.print(array[4]);
		System.out.print(array[2]);
		System.out.print(array[1]);
		System.out.print(array[0]);
		System.out.print(array[6]);
		System.out.print(array[3]);	
	}
}

public class Program {
	public static void main(String[] args) {
		char[] j = { 'r', 'g', 'o', 'm', 'r', 'p', 'a' };
		Sorting sorting = new Sorting();
		sorting.sort(j);
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS