Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having trouble with a question and I am not sure why my answer is still incorrect. The question is My code import java.util.Scanner; public

I'm having trouble with a question and I am not sure why my answer is still incorrect.

The question is image text in transcribed

My code

import java.util.Scanner; public class StateCapital { public static void main(String[] args) { Scanner input = new Scanner(System.in); int correctCount = 0; for (int i = 0; i

private static String[][] stateCapitals = { {"Alabama", "Montgomery"}, {"Alaska", "Juneau"}, {"Arizona", "Phoenix"}, {"Arkansas", "Little Rock"}, {"California", "Sacramento"}, {"Colorado", "Denver"}, {"Connecticut", "Hartford"}, {"Delaware", "Dover"}, {"Florida", "Tallahassee"}, {"Georgia", "Atlanta"}, {"Hawaii", "Honolulu"}, {"Idaho", "Boise"}, {"Illinois", "Springfield"}, {"Maryland", "Annapolis"}, {"Minnesota", "Saint Paul"}, {"Iowa", "Des Moines"}, {"Maine", "Augusta"}, {"Kentucky", "Frankfort"}, {"Indiana", "Indianapolis"}, {"Kansas", "Topeka"}, {"Louisiana", "Baton Rouge"}, {"Oregon", "Salem"}, {"Oklahoma", "Oklahoma City"}, {"Ohio", "Columbus"}, {"North Dakota", "Bismark"}, {"New York", "Albany"}, {"New Mexico", "Santa Fe"}, {"New Jersey", "Trenton"}, {"New Hampshire", "Concord"}, {"Nevada", "Carson City"}, {"Nebraska", "Lincoln"}, {"Montana", "Helena"}, {"North Carolina", "Raleigh"}, {"Missouri", "Jefferson City"}, {"Mississippi", "Jackson"}, {"Massachusetts", "Boston"}, {"Michigan", "Lansing"}, {"Pennsylvania", "Harrisburg"}, {"Rhode Island", "Providence"}, {"South Carolina", "Columbia"}, {"South Dakota", "Pierre"}, {"Tennessee", "Nashville"}, {"Texas", "Austin"}, {"Utah", "Salt Lake City"}, {"Vermont", "Montpelier"}, {"Virginia", "Richmond"}, {"Washington", "Olympia"}, {"West Virginia", "Charleston"}, {"Wisconsin", "Madison"}, {"Wyoming", "Cheyenne"} }; }

My answer and the correct answer

image text in transcribed

I just do not see why I keep getting it wrong.

Modify the program below to prompt the user enter the capital for a state. Upon receiving the user input, the program reports whether the answer is correct. 1. Create and complete a two-dimensional array to store the 50 states and their capitals. 2. Display all 50 states and ask the user to enter its capital, one at a time. .Compare the user input with the array. Count the correct answers. 4. Display the total correct count. Example What is the capital for Alabama? What is the capital for Alaska? What is the capital for Delaware? Total correct count: 35 If the user entered a correct answer, display the next question; If the user entered a wrong answer for Delaware, display a message... Sorry, the capital for Delaware is Dover Note: 1.The user's answer is not case-sensitive (equalslgnoreCase) 2. Use printin

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

Students also viewed these Databases questions

Question

What are the APPROACHES TO HRM?

Answered: 1 week ago