0

I am asking the user to input whether they are a teacher or student and use the response to run a menu specific to their answer.

This is what I have so far but even though the input reads out correctly the result is not working in my if/else statement to call the menus.

I am new to java so unsure what is wrong.

public void welcomeUser(){
    //dummy read of String to clear the buffer - bug in Scanner class.
    input.nextLine();

    String userResponse = "";
    do {
        System.out.print("Welcome! Are you a teacher or student? (please type => teacher or student): ");
        userResponse = input.nextLine();
        System.out.print(userResponse);

    }
    while(!userResponse.equals("teacher") && !userResponse.equals("student"));


    if(userResponse.equals("teacher")){
        runTeacherMenu();
    }

    else if(userResponse.equals("student")){
        runStudentMenu();
    }

}

0 Answers0