import java.io.*;
// javac if_else.java
public class if_else
{
public static void main(String args[])throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String str = "";
try{
System.out.println("---Driver Profile---");
System.out.print("Please enter your age: ");
str = br.readLine();
int n =Integer.parseInt(str);
if (n >= 14 && n <=40)
{
System.out.println("Eligible to Drive" );
if (n <= 18) { System.out.println("Needs parent while driving" );}
if (n >= 18 && n <=24) { System.out.println("Eligible Dangerous driver" );}
if (n >= 25 && n <=30) { System.out.println("Eligible Competent driver" );}
}
else
{
if (n >=30 && n <= 60 ) { System.out.println("You are mature driver, be careful" );}
} //end if
}//try
catch(NumberFormatException e) { System.out.println("data was blank");}
}//end of main
}//end of clas]
 

with Text pad

the block if-else check an alternate pass if condition is not true

import java.util.*;
import java.io.*;
//javac if_else_exit.java
public class if_else_exit
{
private static int player_no = 24;
public static String str;
public if_else_exit()
{ System.out.println("This is a constructor with no param");
}
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Type a number :");
str = br.readLine();
int n2 = Integer.parseInt(str);
if(n2>=10)
{
System.out.println("You may to this ride :");
}
else
{
System.out.println("sorry :" + n2 + " age should be >=10");
}
System.out.print("Type a word :");
str = br.readLine();
if(str.equals("exit"))
{
System.out.print("Are you sure");
}
}
}