Question: Rewrite Programming Exercise 8.37? to store pairs of each state and its capital in a map. Your program should prompt the user to enter a

Rewrite Programming Exercise 8.37?to store pairs of each state and its capital in a map. Your program should prompt the user to enter a state and should display the capital for the state.

Write a program that repeatedly prompts the user to enter a capital for a state. Upon receiving the user input, the program reports whether the answer is correct. Assume that?50?states and their capitals are stored in a two dimensional array, as shown in Figure. The program prompts the user to answer all states? capitals and displays the total correct count. The user?s answer is not case-sensitive.

Alabama Alaska Arizona Montgomery Juneau Phoenix What is the capital of Alabama?

Here is a sample run:

Montogomery -Enter The correct answer should be Montgomery What is the capital

Alabama Alaska Arizona Montgomery Juneau Phoenix What is the capital of Alabama? Montogomery -Enter The correct answer should be Montgomery What is the capital of Alaska? Juneau -Enter Your answer is correct What is the capital of Arizona? ... The correct count is 35

Step by Step Solution

3.50 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Output Enter a state New York The capital is Albany This program uses to enter a ... View full answer

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 Java Programming Questions!