Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ask: Create a project called CitySorter_FirstName_LastName or Lab7_FirstName_LastName. emember to include comments summarizing the program. 1. Declare a Scanner that accepts input from the keyboard.

image text in transcribedimage text in transcribed

ask: Create a project called CitySorter_FirstName_LastName or Lab7_FirstName_LastName. emember to include comments summarizing the program. 1. Declare a Scanner that accepts input from the keyboard. 2. Declare the following three variables in your program: - Three variables of type String that will hold three different cities the user enters You may also consider three variables of type boolean to hold comparisons between the cities. 3. Prompt the user three times to enter each of the three cities. Use the appropriate method of the Scanner class to assign each of the user's inputs to the appropriate String variable. 4. The order of the cities will depend on the order of the statements to print those cities to the console. To determine the order to print the cities in, you will need to compare the cities using the appropriate method of the String class. Assume that case does not matter and that the user enters three different cities. You must do comparisons between all pairs of cities to determine the correct order. For example, to determine if the last city that the user enters comes first alphabetically, compare this city to the other two cities. If the last city entered by the user does come first alphabetically, print that city and then compare the remaining two cities. Whichever comes second alphabetically is printed next, and then whichever comes last alphabetically is printed last. As an additional hint, there are six possible initial orderings the user could enter the cities in. The following are two different examples of the user's inputs with different cities in different initial orderings. The final output should be the cities the user entered in alphabetical order. Please enter the first city: San Antonio Please enter the second city: Houston Please enter the third city: Dallas Dallas Houston San Antonio Please enter the first city: Austin Please enter the second city: Waco Please enter the third city: College Station Austin College station Waco

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

6. Explain how to train managers to coach employees.

Answered: 1 week ago