JAVA Program using Interface to Display Employee Salary Sheet

JAVA Program using Interface to Display Employee Salary Sheet:

class employee
{
 int empno;
 String name;
 String desig;

 void getPerson(int eno, String ename, String des)
 {
  empno = eno;
  name= ename;
  desig = des;
 }

 void putPerson()
 {
  System.out.print(" "+empno);
  System.out.print(" "+name);
  System.out.print(" "+desig);
 }
}

class basicpay extends employee
{
 int basic,da;

 void getBasic(int b, int d)
 {
  basic = b;
  da = d;
 }

 void putBasic()
 {
  System.out.print(" "+basic);
  System.out.print(" "+da);
 }
}

interface ini_value
 {
 final static int hra = 3000;
 final static float pf = 0.3f;
 void disphra();
 }

class salary extends basicpay implements ini_value
 {
  float total,tpf,tdedn,npay;

  public void disphra()
  {
   System.out.print("  "+hra);
  }

  void calculation()
  {
   total = (float)(basic + da + hra);
   tpf = basic * pf;
   tdedn = tpf;
   npay = total - tdedn;
   putPerson();
   putBasic();
   disphra();
   System.out.print("   "+total);
   System.out.print("   "+tpf);
   System.out.print("   "+tdedn);
   System.out.print("    "+npay);

   System.out.println("\n-----------------------------------------------------------------------------------------");
   }
  }

  class Interfacesalay
  {
   public static void  main(String args[])
   {
    salary emp[] = new salary[3];
    for(int i=0; i<3;i++)
    emp[i]= new salary();

    emp[0].getPerson(111," Radhakrishanan ","Manager    ");
    emp[1].getPerson(112," JayPraksh      ","Ast.Manager");
    emp[2].getPerson(113," BalKrishanan   ","Supervisor ");
    emp[0].getBasic(9500,3500);
    emp[1].getBasic(9000,3000);
    emp[2].getBasic(8500,2500);
    System.out.println("                              Salary Sheet\n\n");
    System.out.println("-----------------------------------------------------------------------------------------");
    System.out.println("Emp.No Employee Name  Designation Basic D.A. H.R.A. Gross pay  P.F.  Gross Dedn. Net.Pay");
    System.out.println("-----------------------------------------------------------------------------------------");
    for(int i=0; i<3;i++)
    emp[i].calculation();
    }
  }

OUTPUT:

                              Salary Sheet


-----------------------------------------------------------------------------------------
Emp.No Employee Name  Designation Basic D.A. H.R.A. Gross pay  P.F.  Gross Dedn. Net.Pay
-----------------------------------------------------------------------------------------
 111  Radhakrishanan  Manager     9500 3500  3000   16000.0   2850.0   2850.0    13150.0
-----------------------------------------------------------------------------------------
 112  JayPraksh       Ast.Manager 9000 3000  3000   15000.0   2700.0   2700.0    12300.0
-----------------------------------------------------------------------------------------
 113  BalKrishanan    Supervisor  8500 2500  3000   14000.0   2550.0   2550.0    11450.0
-----------------------------------------------------------------------------------------

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.