import java.util.Scanner;
import java.io.*;
class Employee{
public static void main(String args[]){
String name;
int age;
System.out.println("ENTER EMPLOYEE DETAILS");
System.out.println("Enter Name and Age Of The Employee:");
Scanner in=new Scanner(System.in);
try
{
if(!(in.nextLine().matches("[a-zA-Z]+"))){
throw new IOException("Please Enter The Name in Aplhabets");
}
age=in.nextInt();
if(age>50){
System.out.println("Age greater than 50 Exception");
throw new Exception("You Are Too Old to Work , Take Retirement");
}
Employee x=new Employee();
System.out.println("Object Created");
}
catch(Exception ex){
System.out.println(ex.getMessage());
}
}
}
import java.io.*;
class Employee{
public static void main(String args[]){
String name;
int age;
System.out.println("ENTER EMPLOYEE DETAILS");
System.out.println("Enter Name and Age Of The Employee:");
Scanner in=new Scanner(System.in);
try
{
if(!(in.nextLine().matches("[a-zA-Z]+"))){
throw new IOException("Please Enter The Name in Aplhabets");
}
age=in.nextInt();
if(age>50){
System.out.println("Age greater than 50 Exception");
throw new Exception("You Are Too Old to Work , Take Retirement");
}
Employee x=new Employee();
System.out.println("Object Created");
}
catch(Exception ex){
System.out.println(ex.getMessage());
}
}
}
No comments:
Post a Comment