Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The lab this week focuses on sorting words alphabetically. In order to do this, you will need to use if-else if-else statements that make use

The lab this week focuses on sorting words alphabetically. 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. 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 statements to 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 must then compare the remaining two words to each other to determine which comes second alphabetically and which comes last alphabetically.

It is important to note that each output should be evaluated alphabetically for every letter in the input word, not just the first letter.

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

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago