Can someone help me figure out why is this not working.....
The program supposse to take the data i load into the hashmap from the file and look for the user enters. and suppose to output the answer based on the case. thanks

import java.io.File;
import java.util.HashMap;
import java.util.Scanner;

import javax.swing.InputMap;

public class Main {


    public static int menu() {

        int userChoice;
        Scanner input = new Scanner(System.in);

        /***************************************************/

        System.out.println("                Choose from these choices                          ");
        System.out.println("                -------------------------\n");
        System.out.println("1 - Type 1 to Enter an Abbreviation of the state you would like the population for. ");
        System.out.println("2 - Type 2 to Enter Name of the State you would like the population for. ");
        System.out.println("3 - Type 3 to find the population for whole United States(Census 2010). ");
        System.out.println("4 - Type 4 to Exit the Program.");

       userChoice = input.nextInt();
       return userChoice;


//Once you have the method complete you would display it accordingly in your main method as follows:

    public static void main(String[] args) {


         //int userChoice;
        //Scanner input = new Scanner(System.in);



        int userChoice = menu();

        //from here I can either use a switch statement on the userchoice 
        //or I can use a while loop (while userChoice != the fourth selection
        //using if/else statements to do my actual functions for the given choices.
        File stateNames = new File("stateName.txt");
        Scanner scan1 = new Scanner(stateNames).useDelimiter("[,\n\r]+");
        Scanner scan = new Scanner(System.in);

        HashMap<String, String> states = new HashMap<>();

        String stateName;
        String stateAbbrev;

        /*while (scan1.hasNext()) {
            stateName = scan1.next();
            stateAbbrev = scan1.next();
            states.put(stateName, stateAbbrev); */


    do
        {
        int userchoice = 0;
        //String stateName;
        //String stateAbbrev;
        int statePop;


    Scanner selection =  new Scanner(System.in);


    userChoice = selection.nextInt();

        }
    while {



        Switch(userchoice){

            Case 1:

                Scanner input = new Scanner(System.in);
                String state = input.nextLine();
                System.out.print("the abbreviation for " + stateName + "is " + stateAbbrev);

                break;

            Case2: 

             input1 = new Scanner(System.in);
            String abbrev = InputMap.nextLine();
            System.out.println(stateAbbrev + stateName);
            break;

            Case3:

                input1 = new Scanner(System.in);
                System.out.println(stateAbbrev + statePop);
                break;

                case 4:
                    default;
                    break;


        }

        }

This isn't working, because this will not compile. Java is case sensitive, meaning 'switch' and 'Switch' and 'case' and 'Case' are not the same things.

This article has been dead for over six months. Start a new discussion instead.