samedi 25 juin 2016

Creating a Basic JAVA phone book

I'm just learning JAVA and trying to make a simple phone book. For this part I'm trying to prompt the user to choose one of the 3 options below.

public class PhoneBook {

    public static void main (String[] args){
        options();      
        /*This method prompts the user to enter phone number
        String s;
        Scanner in = new Scanner(System.in);
        System.out.println("Enter Phone Number");
        s = in.nextLine();
        System.out.println("You entered phone number ");
        System.out.println(s);*/
    }

    public static void options (){
    //This method gives the user choices on what to do

        char choice;
        char enterNumber = 'n';
        char showNumber = 's';
        char closeBook = 'c';

        String read;
        String freeLine = "error";
        Scanner keyboard = new Scanner(System.in);
        while (true){

            System.out.println("Please select from the following");
            System.out.println("n to Enter the number");
            System.out.println("s to Show the number ");
            System.out.println("c to Close the Phone book");

        read = keyboard.nextLine(); 
        choice = read.charAt(0);
        switch (choice) {
        case 'n': enterNumber; 
                system.out.println();
        case 's':showNumber;
                system.out.println();
        case 'c': closeBook;
                    break;
        default: System.out.println("Invalid Entry");


        } 
        }
    }

}

When I compile it i get errors on lines 37, 39, and 41 saying "Error: not a statement". I feel like something is missing. If anyone can help it would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire