You are on page 1of 2

15.

An organization maintains the records of all its employees as per the designation and the
hierarchy of the designation. Each employee has his basic information and allowances are decided as
per the hierarchy of the designation. e. g. Normal Employee gets basic salary Rs. 5000 per month. If
that employee is Manager, he gets 20% of basic as HRA additional. If that employee is Head of any
department, he gets HRA + 10% of basic as Child Education Allowance. Create Java program using
inheritance to solve this problem.

Code:

import java.io.*;

class Employe

int empid;

String ename;

double basicsalary=5000;

double totalSalary()

return basicsalary;

class Manager extends Employe

double hra;

double totalHra()

hra= (super.totalSalary()+(super.totalSalary()*20/100));

return hra;

class Hod extends Manager


{

double tothodsal;

double totalCea()

tothodsal = (super.totalHra()+(super.totalSalary()*10/100));

return tothodsal;

public class OrganizationDemo

public static void main(String args[])

Employe e1 = new Employe();

System.out.println("Salary of Normal employee is : "+e1.totalSalary());

Manager m1 = new Manager();

System.out.println("Salary of Manager is : "+m1.totalHra());

Hod h1 = new Hod();

System.out.println("Salary of HOD is : "+h1.totalCea());

You might also like