Question: Solve this in java please 6.6 A Sorted Affair Code is already provided to allow the user to type a list of words, store the

Solve this in java please

Solve this in java please 6.6 A Sorted Affair Code is already

provided to allow the user to type a list of words, store

the list as an array, and call the sortReport method. You will

6.6 A Sorted Affair Code is already provided to allow the user to type a list of words, store the list as an array, and call the sortReport method. You will write new code to implement sortReport. Your code should analyze whether the input array is sorted and return as follows. - if the array is sorted alphabetically from a to z : return "sorted X" where X is replaced by the number of items in the input array - if the array is not sorted: return a string consisting of the index of the first word that is out of order, a blank space, and the word. Several examples are below (user input in bold underline text): Word list: grape banana orange melon 1 banana Word list: banana melon grape orange 2 grape Word list: banana grape melon orange plum apple 5 apple Word list: banana grape melon orange sorted 4 Word list: banana sorted 1 Word list: banana grape melon orange sorted 4 Word list: banana sorted 1 Word list: apple banana grape melon orange peach plum sorted 7 SortedAffair.java Load default templat \begin{tabular}{r|c} 1 & import java.util. Arrays; \\ 2 & import java.util. Scanner; \\ 3 & \\ 4 & public class SortedAffair \{ \\ 5 & \\ 6 & public static void main(String[ args) \{ \\ 7 & \\ 8 & Scanner console = new Scanner(System.in); \\ 9 & \\ 10 & System.out.print("Word list: "); \\ 11 & String input = console.nextLine(); \\ 12 & String[] words = input.split(" "); \\ 13 & \\ 14 & String analysis = sortReport(words); \\ 15 & System.out.println(analysis); \end{tabular} \begin{tabular}{l|l} LAB & 6.6.1: A Sorted Affair \end{tabular} 0/120 SortedAffair.java Load default template

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!