Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions

Question

5-4 What are the current computer software platforms and trends?

Answered: 1 week ago

Question

Explain the testing process of accounting 2?

Answered: 1 week ago

Question

=+Where do you want to live and work?

Answered: 1 week ago

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago