Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 templateStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started