Program for employee information.

import java.io.*;
class Person
{
String name;
int age;
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
void accept()
{
try
{
System.out.print("Enter the Name : ");
name = br.readLine();
System.out.print("Enter the Age : ");
age = Integer.parseInt(br.readLine());
}
catch(Exception e) { }
}
void display()
{
System.out.println("Name : "+name);
System.out.println("Age : "+age);
}
};

class Employee extends Person
{
String designation;
double salary;
void accept()
{
super.accept();
try
{
System.out.print("Enter Employee Designation : ");
designation = br.readLine();
System.out.print("Enter Employee Salary : ");
salary = Double.parseDouble(br.readLine());
}
catch(Exception e) { }
}
void display()
{
super.display();
System.out.println("Employee Designation : "+designation);
System.out.println("Employee Salary : "+salary);
}
};

class Exp9_1
{
public static void main(String[] args)
{
Employee e = new Employee();
e.accept();
System.out.println("=================================");
e.display();
}
}

No comments:

Post a Comment