I am new in core java and wrote a nested if statement code. I'm facing the problem when nested condition is satisfied and print statement "you will get 40% discount of fair" is not getting executed.
import java.util.Scanner;
public class Ifstatement {
static int age ;
static String Gender;
public static void main(String[] args) {
Scanner obj = new Scanner (System.in);
System.out.print("Enter the age: ");
age = obj.nextInt();
System.out.print("Enter the Gender: ");
Gender= obj.next();
System.out.println("Gender is "+ Gender);
System.out.println("Age is "+ age);
if (age<=14)
{
System.out.println(" you will get 30% discount of fair ");
if(Gender== "F")
{
System.out.println("you will get 40% discount of fair");
}
}
if (age>=14)
{
System.out.print("you will get 20% discount of fair");
}
}
}