Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Word Sorter In order to do this, you will need to use if-else if-else statements that make use of logical operators and methods for String

Word Sorter

In order to do this, you will need to use if-else if-else statements that make use of logical operators and methods for String comparisons.

Task:Create a project called WordSorter_FirstName_LastName or Remember to include comments summarizing the program.

1.Import the Scanner class and construct an object of the Scanner class that reads keyboard input.

2.Declare three String variables that will hold three different words the user enters.

3.Print three requests to the user asking for the first, second, and third word. Store the users input for each of these requests into each of the three String variables.

4.The order of the words will depend on the order of the statementsto print those words to the console. To determine the order to print the words in, you will need to compare the words using the appropriate method of the String class.Assume that case does not matter and that the user enters three different words.Additionally, you must do comparisons between all pairs of words to determine the correct order.

For example, to determine if the last word that the user enters comes first alphabetically, you must compare this word to the other two words.If the last word does come first alphabetically, you mustthen compare the remaining two words to each other to determine which comes second alphabetically and which comes last alphabetically.

The following are two examples of the users inputs with different words in different initial orderings. The final output should be the words the user entered in alphabetical order.

run:

Please enter the first word: Candy

Please enter the second word: apple

please enter the third word: banana

apple

banana

candy

BUILD SECCESSFL (total tie: 8 seconds)

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

Explain the causes of indiscipline.

Answered: 1 week ago