0

I am trying to create a method for some options that a user my have. If the user will input s, f or q some actions will happen but I have an issue with comparison in while conditions. So basically while option is not equal to s,f or q this method will keep on prompting the error message and will ask the user to input an option. I tried to use the bellow code but it keeps on saying that the selection is invalid even if I input s,f

public String options(){    
        System.out.println("Options: (s)elect a floor, (f)ire alarm, (q)uit");
        String option= read.next();

        while(!option.equalsIgnoreCase("select") || !option.equalsIgnoreCase("fire") || !option.equalsIgnoreCase("quit")){
        System.out.println("Invalid selection!");
        System.out.println("Options: (s)elect a floor, (f)ire alarm, (q)uit");
        option= read.next();

        }

    return option;
    }//end options
  • Your code is looking for "select", "fire" or "quit". And you give it "s", "f" and "r". – Antoine Apr 03 '17 at 13:51
  • Thank you very much T.J. Crowder! I reviewed that post and now it's all clear and I wonder why I didn't think about it. – gabrielT Apr 04 '17 at 16:09

0 Answers0