My java code doesnt continue to the next print statement

My code executes up to the point where it prints the array of states and capitals but then it stops and doesnt continue to the next print statement where I ask the user the quiz questions about state capitals
Repl link:
https://replit.com/@NickStraub/States#Main.java

package ArraySort;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    //Establishing Variables
    
    BubbleSort bubble = new BubbleSort();
    Scanner sc = new Scanner(System.in);
    int score = 0;
    String scanline;
    
  
  
    //Creating states and capitals array
    String[][] statesAndCapitals = {
      {"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"},
			{"Indiana","Indianapolis"},
			{"Iowa","Des Moines"},
			{"Kansas","Topeka"},
			{"Kentucky","Frankfort"},
			{"Louisiana","Baton Rouge"},
			{"Maine","Augusta"},
			{"Maryland","Annapolis"},
			{"Massachusetts","Boston"},
			{"Michigan","Lansing"},
			{"Minnesota","St. Paul"},
			{"Mississippi","Jackson"},
			{"Missouri","Jefferson City"},
			{"Montana","Helena"},
			{"Nebraska","Lincoln"},
			{"Nevada","Carson City"},
			{"New Hampshire","Concord"},
			{"New Jersey","Trenton"},
			{"New Mexico","Santa Fe"},
			{"New York","Albany"},
			{"North Carolina","Raleigh"},
			{"North Dakota","Bismarck"},
			{"Ohio","Columbus"},
			{"Oklahoma","Oklahoma City"},
			{"Oregon","Salem"},
			{"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"}
		};

    //Display Array of states and capitals
    System.out.println("Here is a list of every state and their capital:");


    //Display contents of the Array
    for (int i = 0; i < 50; i++) {
      System.out.println(statesAndCapitals[i][0] + " -- " + statesAndCapitals[i][1] + ",\n");
      
    }
    
  //Sort the array with bubble sort
bubble.bubbleSort(statesAndCapitals);

  
  System.out.println("Please enter the capital for each state:");

//Ask the user all captials of all states using a loop
    for (int i =0; i < 50; i++) {
      System.out.println("What is the capital of " + statesAndCapitals[i][0] + " ?:");
      scanline = sc.nextLine().toLowerCase();
      if (scanline.equals(statesAndCapitals[i][1].toLowerCase())) {
        System.out.println("Correct\n");
        score++;
        
      } else {
        System.out.println("Incorrect, the correct answer is " + statesAndCapitals[i][1] + ".");
        
      }
    }
System.out.println("Your score is " + score + " out of 50.");


sc.close();
  
  }
}

you have to keep this removed because otherwise the updated Main.class goes in a subfolder which replit doesn’t run

1 Like