-1

Hi stackers,

      System.out.print("Enter your first name:  ");
  firstName = keyboard.nextLine();
  if(firstName!="Mike"&&firstName!="mike"&&firstName!="Diane"&&firstName!="diane")
  {
      System.out.println("derp");
  }
  else
      discount=true;

however, this is the result:

Enter your first name:  diane
derp

if anyone can tell me what I'm doing wrong that would be great thank you very much!

Metalmine
  • 71
  • 1
  • 7

1 Answers1

0
public class Test{

    public static void main(String[] args) {

        System.out.print("Enter your first name:  ");
        Scanner keyboard = new Scanner(System.in);
        String firstName = keyboard.nextLine();
        if (!(firstName.equalsIgnoreCase("mike") || (firstName.equalsIgnoreCase("diane")))) {
            System.out.println("derp");
        } else
            System.out.println("true");
    }
}

Output

Enter your first name:  diane
true
Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116