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:

package ArraySort;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    //Establishing Variables
    BubbleSort bubble = new BubbleSort();
    Scanner sc = new Scanner(;
    int score = 0;
    String scanline;
    //Creating states and capitals array
    String[][] statesAndCapitals = {
			{"Arkansas","Little Rock"},
			{"Iowa","Des Moines"},
			{"Louisiana","Baton Rouge"},
			{"Minnesota","St. Paul"},
			{"Missouri","Jefferson City"},
			{"Nevada","Carson City"},
			{"New Hampshire","Concord"},
			{"New Jersey","Trenton"},
			{"New Mexico","Santa Fe"},
			{"New York","Albany"},
			{"North Carolina","Raleigh"},
			{"North Dakota","Bismarck"},
			{"Oklahoma","Oklahoma City"},
			{"Rhode Island","Providence"},
			{"South Carolina","Columbia"},
			{"South Dakota","Pierre"},
			{"Utah","Salt Lake City"},
			{"West Virginia","Charleston"},

    //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

  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())) {
      } else {
        System.out.println("Incorrect, the correct answer is " + statesAndCapitals[i][1] + ".");
System.out.println("Your score is " + score + " out of 50.");


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

1 Like