Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions