jeudi 31 août 2017

If/Else statement error [duplicate]

This question already has an answer here:

I'm trying to work on a basic text based "game" to experiment and see certain java functions in use/learn how to debug java code. I've run into an issue where a if/if else statement is print both outcomes if it meets the first section's criteria. I'm not sure what the problem is after looking through it and making changes, nothing I've tried has worked.

        //Initial name input
    System.out.println("Welcome, please input your name...");
    String name = ask.nextLine();
    System.out.println("Your name is "+name+", correct?");

    //Response the name accuracy
    System.out.println("\n(Type Y or N)");
    String nameResponse = ask.nextLine();

    //Name change/correction If/Else block
    if(nameResponse.equals("Y")) {
        System.out.println("Great!");
        }
        else if (nameResponse.equals("N"));{
            System.out.println("What is it then?");
            name = ask.nextLine();
            System.out.println("Oh, so your name is "+name);

Aucun commentaire:

Enregistrer un commentaire