Question: Write a program to allow the user to enter the names of states they would like to visit. Stop prompting for states when the user

Write a program to allow the user to enter the names of states they would like to visit. Stop prompting for states when the user enters "Stop". Store all of the state names entered in an ArrayList. Do not store "Stop".
After all states have been entered, the program should print the state names all on one line each separated by a space, an arrow (->) and a space. Do not print an arrow at the end of the list of states. You must use a for loop to traverse the list. The prompts and output must be formatted exactly as is shown in this sample run.
Be sure to allow input of states with two part names.
Here are two sample runs:
Enter the name of a state or "Stop" to quit: Florida
Next state or "Stop": New Mexico
Next state or "Stop": Texas
Next state or "Stop": Oregon
Next state or "Stop": New York
Next state or "Stop": Stop
Florida -> New Mexico -> Texas -> Oregon -> New York
Enter the name of a state or "Stop" to quit: Maine
Next state or "Stop": Georgia
Next state or "Stop": Missouri
Next state or "Stop": Tennessee
Next state or "Stop": Kentucky
Next state or "Stop": Arizona
Next state or "Stop": South Dakota
Next state or "Stop": Montana
Next state or "Stop": Stop
Maine -> Georgia -> Missouri -> Tennessee -> Kentucky -> Arizona -> South Dakota -> Montana

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!