import java.util.Scanner;
class Employee {
String name;
String address;
int age;
Double salary;
Long phno;
public void printSalary() {
System.out.println("Salary of employee: "+salary);
}
}
class Officer extends Employee {
String specialization;
public void readData() {
Scanner sobj = new Scanner(System.in);
System.out.println("Enter the name of Officer: ");
name = sobj.next();
System.out.println("Enter the address of Officer: ");
address = sobj.next();
System.out.println("Enter the age of Officer: ");
age = sobj.nextInt();
System.out.println("Enter the salary of Officer: ");
salary = sobj.nextDouble();
System.out.println("Enter the phone no of Officer: ");
phno = sobj.nextLong();
System.out.println("Enter the specialization of Officer: ");
specialization = sobj.next();
}
public void printData() {
System.out.println("\nName of Officer = " + name);
System.out.println("Age of Officer = " + age);
System.out.println("Address of Officer = " + address);
printSalary();
System.out.println("Phone no of Officer = " + phno);
System.out.println("Specialization of Officer = " + specialization);
}
}
class Manager extends Employee {
String department;
public void readData() {
Scanner sobj = new Scanner(System.in);
System.out.println("Enter the name of Manager: ");
name = sobj.next();
System.out.println("Enter the address of Manager: ");
address = sobj.next();
System.out.println("Enter the age of Manager: ");
age = sobj.nextInt();
System.out.println("Enter the salary of Manager: ");
salary = sobj.nextDouble();
System.out.println("Enter the phone no of Manager: ");
phno = sobj.nextLong();
System.out.println("Enter the department of Manager: ");
department = sobj.next();
}
public void printData() {
System.out.println("\nName of Manager = " + name);
System.out.println("Age of Manager = " + age);
System.out.println("Address of Manager = " + address);
printSalary();
System.out.println("Phone no of Manager = " + phno);
System.out.println("Department of Manager = " + department);
}
}
public class Office {
public static void main(String[] args) {
Officer officer1 = new Officer();
Manager manager1 = new Manager();
manager1.readData();
officer1.readData();
manager1.printData();
officer1.printData();
}
}