-4
import java.util.Scanner;

public class StateCapital {

    public static void main(String[] args) {
        Scanner scnr = new Scanner(System.in);

/*
        FIXME: Delcare...
            1. A string variable to store the user input
            2. An integer variable to count the total correct answers
*/


      // FIXME: Initialize a multi-dimensional string array


        // FIXME: Complete the array to store the state and capital names
        stateCapital[0][0] = "Alabama";             stateCapital[0][1] = "Montgomery";
        stateCapital[1][0] = "Alaska";              stateCapital[1][1] = "Juneau";
        stateCapital[2][0] = "Arizona";             stateCapital[2][1] = "Phoenix";
        stateCapital[3][0] = "Arkansas";            stateCapital[3][1] = "Little Rock";
        stateCapital[4][0] = "California";          stateCapital[4][1] = "Sacramento";
        stateCapital[5][0] = "Colorado";               stateCapital[5][1] = "Denver";
        stateCapital[6][0] = "Connecticut";         stateCapital[6][1] = "Hartford";
        stateCapital[7][0] = "Delaware";               stateCapital[7][1] = "Dover";
        stateCapital[8][0] = "Florida";             stateCapital[8][1] = "Tallahassee";
        stateCapital[9][0] = "Georgia";             stateCapital[9][1] = "Atlanta";

        stateCapital[20][0] = "Massachusetts";      stateCapital[20][1] = "Boston";
        stateCapital[21][0] = "Michigan";           stateCapital[21][1] = "Lansing";
        stateCapital[22][0] = "Minnesota";          stateCapital[22][1] = "St. Paul";
        stateCapital[23][0] = "Mississippi";        stateCapital[23][1] = "Jackson";
        stateCapital[24][0] = "Missouri";           stateCapital[24][1] = "Jefferson City";
        stateCapital[25][0] = "Montana";               stateCapital[25][1] = "Helena";
        stateCapital[26][0] = "Nebraska";           stateCapital[26][1] = "Lincoln";
        stateCapital[27][0] = "Nevada";             stateCapital[27][1] = "Carson City";
        stateCapital[28][0] = "New Hampshire";      stateCapital[28][1] = "Concord";
        stateCapital[29][0] = "New Jersey";         stateCapital[29][1] = "Trenton";

        stateCapital[40][0] = "South Dakota";       stateCapital[40][1] = "Pierre";
        stateCapital[41][0] = "Tennessee";          stateCapital[41][1] = "Nashville";
        stateCapital[42][0] = "Texas";              stateCapital[42][1] = "Austin";
        stateCapital[43][0] = "Utah";                  stateCapital[43][1] = "Salt Lake City";
        stateCapital[44][0] = "Vermont";               stateCapital[44][1] = "Montpelier";
        stateCapital[45][0] = "Virginia";           stateCapital[45][1] = "Richmond";
        stateCapital[46][0] = "Washington";         stateCapital[46][1] = "Olympia";
        stateCapital[47][0] = "West Virginia";      stateCapital[47][1] = "Charleston";
        stateCapital[48][0] = "Wisconsin";          stateCapital[48][1] = "Madison";
        stateCapital[49][0] = "Wyoming";               stateCapital[49][1] = "Cheyenne";

        // FIXME: Ask the user to guess the capitals for all 50 states, display one state at a time; Use for loop
        System.out.println("What is the capital for Delaware?");


        // FIXME: Modify the statement below to print total correct count
        System.out.println("Total correct count: 35");


    }

}

what i need is to figure out how to get this program to work as i am stumped and even my teacher doesnt know exactly how to solve this program

Yassin Hajaj
  • 20,020
  • 9
  • 41
  • 81
  • 2
    Maybe there's a question? – Yassin Hajaj Apr 06 '16 at 22:38
  • Reasons to downvote: **a)** We don't know what your exact problem is. **b)** you didn't explicitly ask a question. **c)** we're not going to fix your code for you when you haven't ran a debugger or told us what you've tried.. – Aaron Gillion Apr 07 '16 at 00:28

1 Answers1

0

Pick a random number from 0 to 49. This will let you choose which state you want to let the user guess the capital of.

// this should give you a number between 0 and 49. 
// [Someone, please correct me if the bounds are wrong.]
int randomRow = (int) ( Math.random() * (49+1) ); 

Now, the 0th index, i.e., stateCapital[randomRow][0] is the name of the state and the 1th index is the capital. Ask the user a question and read in his/her input using a Scanner. Compare the inputted answer to the 1th index.

I hope this will set you on the track to successfully complete your assignment. Let me know if there are any questions.

Community
  • 1
  • 1
Debosmit Ray
  • 4,731
  • 2
  • 21
  • 41