Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class StateCapitals {
- public static void main(String[] args) {
- //create an array of state capitals and their states
- Scanner kb = new Scanner(System.in);
- int counter = 0; // I did not immediately recognize I needed this
- String[][] capitals = {
- {"Arkansas" , "Little Rock"},
- {"Texas", "Austin"},
- {"Louisiana", "Baton Rouge"},
- {"New Mexico", "Santa Fe"}
- };
- for (int i=0; i<capitals.length; i++) {
- String temp;
- System.out.println("What is the capital of "+ capitals[i][0]);
- temp = kb.nextLine();
- if (temp.equalsIgnoreCase(capitals[i][1])) {
- System.out.println("That is correct");
- counter++;
- }
- else
- System.out.println("The correct answer is "+ capitals[i][1]);
- }
- System.out.println("You got "+ counter + " correct.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement