Q:

If user input doesn't meet conditions, return message

So I'm really new to Java, and what I'm trying to do is let the user input a keyword, which will be passed to different conditions. If the keyword starts with "c", it will execute cmethod. If the keyword starts with "n", it will execute nmethod. 
The problem is, I also want to display a message if the user inputs neither something that starts with "c" or "n". Here's what I've been able to think through (I'm aware that this code won't work though)
    public static void main(String[] args) {
    System.out.println("This program can randomize characters or numbers.");
    System.out.println("Please input \"c\" for characters, and \"n\" for numbers. ");
    Scanner choices = new Scanner(System.in);

    if (choices.next().startsWith("c")) {
        cmethod();
    }

    else {
        nmethod();
    }

    //how do I execute the code below if none of the conditions are met?
    else {
        System.out.println("Keyword is wrong.");
    }
}

EDIT : Tried to use else if, but then for nmethod() to be executed, the user have to type in "n" twice.

A:

You have to extract next() to a variable. If you don't do it, next() will always return the current keyword and move on to the next one.
Additionally you have to use else if if you want to check for another keyword.
public static void main(String[] args) {
    System.out.println("This program can randomize characters or numbers.");
    System.out.println("Please input \"c\" for characters, and \"n\" for numbers. ");
    Scanner choices = new Scanner(System.in);

    String keyword = choices.next();

    if (keyword.startsWith("c")) {
        cmethod();
    } else if (keyword.startsWith("n")) {
        nmethod();
    } else {
        System.out.println("Keyword is wrong.");
    }
}

