Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS141 - Lab 5 Following is a description of the basic idea for this lab. Note that there are several modifications and clarifications listed below

image text in transcribed

image text in transcribed

CS141 - Lab 5 Following is a description of the basic idea for this lab. Note that there are several modifications and clarifications listed below it. **8.37 (Guess the capitals) 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 8.10. 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 FIGURE 8.10 A two-dimensional array stores states and their capitals Here is a sample run: What is the capital of Alabama? Montogomery The correct answer should be Montgomer What is the capital of Alaska? Juneau Your answer is correct What is the capital of Arizona? The correct count is 35 . The entire program can be written in the main class, but you must modularize your work into appropriate methods. To create the state capitals array, follow these instructions o Copy the String from this file into your program (found below these instructions). The String is a pipe delimited list of states and capitals isted as statelcapitalI statelcapitaThe list is alphabetical o Read the String into a Scanner object using something like: Scanner scanStr new Scanner(stateCapitals); o You must set the delimiter for the scanner before using it, before the loop o Create the necessary 2D array by declaring the array and then using a for loop to scan o You must also close the scanner when you're done with it, after the loop scanStr.useDelimiter("Wl"); each element using scanStr.next() scanStr.close)

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

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago