import java.io.*;
import java.util.*;
class Numx
{
public static void main(String args[])
{
String name;
int age;
System.out.println("-----ENTER EMPLOYEE DETAILS-----");
System.out.println("Enter Name and Age:");
Scanner in=new Scanner(System.in);
try
{
if(!(in.nextLine().matches("[a-zA-Z]+")))
{throw new IOException();}
age=in.nextInt();
if(age>50)
{
System.out.println("Age greater than 50 Exception");
throw new Exception();
}
Numx x=new Numx();
System.out.println("-----Object Created-----");
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
import java.util.*;
class Numx
{
public static void main(String args[])
{
String name;
int age;
System.out.println("-----ENTER EMPLOYEE DETAILS-----");
System.out.println("Enter Name and Age:");
Scanner in=new Scanner(System.in);
try
{
if(!(in.nextLine().matches("[a-zA-Z]+")))
{throw new IOException();}
age=in.nextInt();
if(age>50)
{
System.out.println("Age greater than 50 Exception");
throw new Exception();
}
Numx x=new Numx();
System.out.println("-----Object Created-----");
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
I have been searching to find a comfort or effective procedure to complete this process and I think this is the most suitable way to do it effectively.
ReplyDeletejantakhoj delhi
output
ReplyDelete