Sorry if the title doesn't make sense. Basically, I'm a noob, and for learning purposes I'm trying to create a basic program which asks first for gender then for age to determine access. The program is sexist for testing purposes. Anyway, heres what I have:
System.out.println("What is your Gender?");
String gender = input.nextLine();
if (gender.equals ("male")){
System.out.println("What is your age?");
int agem = input.nextInt();
if (agem >= 21 && agem < 65){
System.out.println("Access Granted");
}else{
System.out.println("Access Denied");
}
}
if (gender.equals ("female")){
System.out.println("What is your age?");
int agef = input.nextInt();
if (agef >=18 && agef < 60){
System.out.println("Access Granted");
}else{
System.out.println("Access Denied");
}
}
Now what I am trying to do is create a response in case the user enters something other than "male" or "female". I've tried using else in the case that both if statements are false but it hasn't worked.
I also tried creating another if statement like this one:
if (!gender.equals ("male") || ("female"));
But that doesn't work either.
Thanks