Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Find the capitals using maps) Write a program that will create a HashMap that maps the names of the 50 U.S. states to their corresponding

image text in transcribed
(Find the capitals using maps) Write a program that will create a HashMap that maps the names of the 50 U.S. states to their corresponding capitals. Your program will then repeatedly prompt the user to enter a state and will display the capital for the state, or an appropriate error message, until the user enters "done." Your program's output should look like the sample shown below: Enter a state, or "done" when finished: Texas The capital is Austin. Enter a state, or "done" when finished: California The capital is Sacramento. Enter a state, or "done" when finished: Northeast Texas No such state. Enter a state, or "done" when finished: done Hint: To reduce the amount of coding, create a two dimensional array of Strings initialized to store the 50 states in the first column and their corresponding capital in the second column. Then within a loop access the elements of the array and put' them in the HashMap! m

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

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

Students also viewed these Databases questions

Question

2. Identify conflict triggers in yourself and others

Answered: 1 week ago