Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Java Inheritance - Employee #38

Closed
ErSKS opened this issue Aug 14, 2017 · 13 comments
Closed

Implement Java Inheritance - Employee #38

ErSKS opened this issue Aug 14, 2017 · 13 comments

Comments

@ErSKS
Copy link
Owner

ErSKS commented Aug 14, 2017

Employee

  • name
  • dept
  • salary

PermanentEmployee extends Employee

  • pf - boolean
    sal - 10% Increases
    tax - 20%

TemporaryEmployee extends Employee
no pf
tax - 15%

@kajalmaharjan
Copy link

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package inheritance3;

/**
*

  • @author kajal
    */
    public class Inheritance3 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      PermanentEmployee ganesh = new PermanentEmployee();

      ganesh.setName("Bikash");
      ganesh.setSalary(35000);
      ganesh.setDepartment("Computer");
      ganesh.setPf(true);
      ganesh.setSalaryInc(0.1f);
      ganesh.setTax(0.2f);

      float i = (ganesh.getSalaryInc() * ganesh.getSalary());
      float t = (ganesh.getTax() * i);
      float s = (ganesh.getSalary() + i - t);

      System.out.println("Permanent Employee:");
      System.out.println("Name:" + ganesh.getName());
      System.out.println("Department:" + ganesh.getDepartment());
      System.out.println("Pf:" + ganesh.isPf());
      System.out.println("Salary:" + s);

      TemporaryEmployee ravi = new TemporaryEmployee();

      ravi.setName("Ram");
      ravi.setSalary(35000);
      ravi.setDepartment("Computer");
      ravi.setPf(false);
      ravi.setTax(.15f);

      float a = (ravi.getSalary() - ravi.getTax() * ravi.getSalary());
      System.out.println("");
      System.out.println("Temporary Employee:");
      System.out.println("Name:" + ravi.getName());
      System.out.println("Department" + ravi.getDepartment());
      System.out.println("Pf" + ravi.isPf());
      System.out.println("Salary:" + a);

    }

}

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package inheritance3;

/**
*

  • @author som
    */
    public class Employee {

    private String name;
    private String department;
    private float salary;

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getDepartment() {
    return department;
    }

    public void setDepartment(String department) {
    this.department = department;
    }

    public float getSalary() {
    return salary;
    }

    public void setSalary(float salary) {
    this.salary = salary;
    }

}

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package inheritance3;

/**
*

  • @author kajal
    */
    public class PermanentEmployee extends Employee{
    private boolean pf = true;
    private float tax;
    private float salaryInc;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public float getTax() {
    return tax;
    }

    public void setTax(float tax) {
    this.tax = tax;
    }

    public float getSalaryInc() {
    return salaryInc;
    }

    public void setSalaryInc(float salaryInc) {
    this.salaryInc = salaryInc;
    }

}

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package inheritance3;

/**
*

  • @author kajal
    */
    public class TemporaryEmployee extends Employee{
    private float tax;
    private boolean pf = false;

    public float getTax() {
    return tax;
    }

    public void setTax(float tax) {
    this.tax = tax;
    }

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }
    }
    123

@milan604
Copy link

package employeedetail;

/**
*

  • @author m-lan
    */
    public class EmployeeDetail {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      PermanentEmployee E1 = new PermanentEmployee();
      TemporaryEmployee E2 = new TemporaryEmployee();
      E1.setName("Milan Adhikari");
      E1.setDepartment("Computer");
      E1.setSalary(500000);
      E2.setName("Sahas Dongol");
      E2.setDepartment("Civil");
      E2.setSalary(200000);

      System.out.println("Permanent Employee");
      System.out.println("pf: " + E1.isPf());
      System.out.println("Name: " + E1.getName());
      System.out.println("Department: " + E1.getDepartment());
      System.out.println("Final Salary: Rs." + E1.getSalary());
      System.out.println("");
      System.out.println("Temporary Employee");
      System.out.println("pf: " + E2.isPf());
      System.out.println("Name: " + E2.getName());
      System.out.println("Department: " + E2.getDepartment());
      System.out.println("Final Salary: Rs." + E2.getSalary());
      }

}

Class Employee

package employeedetail;

/**
*

  • @author m-lan
    */
    public class Employee {

    private String Name;
    private String Department;
    private double salary;

    public String getName() {
    return Name;
    }

    public void setName(String Name) {
    this.Name = Name;
    }

    public String getDepartment() {
    return Department;
    }

    public void setDepartment(String Department) {
    this.Department = Department;
    }

    public double getSalary() {
    return salary;
    }

    public void setSalary(double salary) {
    PermanentEmployee E1 = new PermanentEmployee();
    TemporaryEmployee E2 = new TemporaryEmployee();
    if (this instanceof PermanentEmployee) {
    this.salary = E1.finalSalary(salary);
    } else {
    this.salary = E2.finalSalary(salary);
    }

    }
    }

Class Permanent Employee

package employeedetail;

/**
*

  • @author m-lan
    */
    public class PermanentEmployee extends Employee {

    private boolean pf = true;

    public boolean isPf() {
    return pf;
    }

    double finalSalary(double s) {
    s += s * 0.1;
    s -= s * 0.2;
    return s;
    }
    }

Class TemporaryEmployee
package employeedetail;

/**
*

  • @author m-lan
    */
    public class TemporaryEmployee extends Employee {

    private boolean pf = false;

    public boolean isPf() {
    return pf;
    }

    double finalSalary(double s) {
    s -= s * 0.15;
    return s;
    }
    }

Output

screenshot from 2017-08-14 18-30-54

@jagdish4249
Copy link

package task14august2;

/**
*

  • @author Jagdish Duwal
    */
    public class Task14August2 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      PermanentEmployee p = new PermanentEmployee();
      p.setName("Ram");
      p.setDept("Human Resources");
      p.setSalary(50000);

      System.out.println("Permanent Employee Description:");
      System.out.println("name: "+ p.getName());
      System.out.println("Department: "+ p.getDept());
      System.out.println("New Salary: "+ p.calcNewSalary(p.getSalary()));
      System.out.println("Tax: "+ p.calcTax(p.calcNewSalary(p.getSalary())));

      TemporaryEmployee t = new TemporaryEmployee();
      t.setName("Sam");
      t.setDept("IT Dept");
      t.setSalary(10000);

      System.out.println("Temporary Employee Description:");
      System.out.println("name: "+ t.getName());
      System.out.println("Department: "+ t.getDept());
      System.out.println("Salary: "+ t.getSalary());
      System.out.println("Tax: "+ t.calcTax(t.getSalary()));
      }

}

class Employee

package task14august2;

/**
*

  • @author Jagdish Duwal
    */
    public class Employee {
    private String name;
    private String dept;
    private double salary=0;

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getDept() {
    return dept;
    }

    public void setDept(String dept) {
    this.dept = dept;
    }

    public double getSalary() {
    return salary;
    }

    public void setSalary(double salary) {
    this.salary = salary;
    }

}

class PermanentEmployee

package task14august2;

/**
*

  • @author Jagdish Duwal
    */
    public class PermanentEmployee extends Employee {
    boolean pf = true;

    double tax;

    double newSalary;

    double calcNewSalary(double salary){

     salary += 0.1 * salary;
     
     return salary;
    

    }

    double calcTax(double nSalary){
    double tax;
    tax = 0.2 * nSalary;

     return tax;
    

    }
    }

class TemporaryEmployee

package task14august2;

/**
*

  • @author Jagdish Duwal
    */
    public class TemporaryEmployee extends Employee{
    boolean pf = false;
    double tax;

    double calcTax(double salary){
    double tax;
    tax = 0.2 * salary;

     return tax;
    

    }

}
capture

@karmi214
Copy link

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package day11_1;

/**
*

  • @author Anish
    */
    public class Day11_1 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      PermanentEmployee p = new PermanentEmployee();
      p.setName("Ganesh");
      p.setSalary(35000);
      p.setDept("Computer");
      System.out.println("Permanent Employee");
      System.out.println("Name of employee:" + p.getName());
      System.out.println("Department:" + p.getDept());
      System.out.println("Salary after tax: " + p.getSalary() * (1 + p.getSal()) * (1 - p.getTax()));
      if (!p.isPf()) {
      System.out.println("The employee does not have provident fund");
      } else {
      System.out.println("The employee has provident fund");
      }
      System.out.println("");
      TemporaryEmployee t = new TemporaryEmployee();
      t.setName("Ram");
      t.setSalary(35000);
      t.setDept("Computer");
      System.out.println("Temporary Employee");
      System.out.println("Name of employee:" + t.getName());
      System.out.println("Department:" + t.getDept());
      System.out.println("Salary after tax: " + t.getSalary() * (1 - t.getTax()));
      if (!t.isPf()) {
      System.out.println("The employee does not have provident fund");
      } else {
      System.out.println("The employee has provident fund");
      }
      }

}
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package day11_1;

/**
*

  • @author Anish
    */
    public class Employee {

    private String dept;
    private String name;
    private double salary;

    public String getDept() {
    return dept;
    }

    public void setDept(String dept) {
    this.dept = dept;
    }

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public double getSalary() {
    return salary;
    }

    public void setSalary(double salary) {
    this.salary = salary;
    }
    }
    /*

  • To change this license header, choose License Headers in Project Properties.

  • To change this template file, choose Tools | Templates

  • and open the template in the editor.
    */
    package day11_1;

/**
*

  • @author Anish
    */
    public class PermanentEmployee extends Employee {

    private boolean pf = true;
    private double sal = 0.1;
    private double tax = 0.2;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public double getSal() {
    return sal;
    }

    public void setSal(double sal) {
    this.sal = sal;
    }

    public double getTax() {
    return tax;
    }

    public void setTax(double tax) {
    this.tax = tax;
    }

}
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package day11_1;

/**
*

  • @author Anish
    */
    public class TemporaryEmployee extends Employee {

    private boolean pf = false;
    private double tax = 0.15;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public double getTax() {
    return tax;
    }

    public void setTax(double tax) {
    this.tax = tax;
    }
    }
    capture

@ajay987
Copy link

ajay987 commented Aug 14, 2017

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeeimplementationn;

/**
*

  • @author Dell
    */
    public class EmployeeImplementationn {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      TemporaryEmployee ga = new TemporaryEmployee();
      ga.setName("ganesh");
      ga.setDept("manager");
      ga.setSalary(35000);
      System.out.println("name:" + ga.getName());
      System.out.println("departmenr:" + ga.getDept());
      System.out.println("salary:" + ga.getSalary());
      System.out.println("tax:" + ga.getTax());
      System.out.println("pf:" + ga.isPf());

      System.out.println("########################################");
      PermanentEmployee hari = new PermanentEmployee();
      hari.setName("hari");
      hari.setDept("ceo");
      hari.setSalary(35000);
      System.out.println("name:" + hari.getName());
      System.out.println("departmenr:" + hari.getDept());
      System.out.println("salary:" + hari.getSalary());
      System.out.println("tax:" + hari.getTax());
      System.out.println("pf:" + hari.isPf());
      }

}

public class Employee {

private String name;
private String dept;
public double salary;

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getDept() {
    return dept;
}

public void setDept(String dept) {
    this.dept = dept;
}

public double getSalary() {
    return salary;
}

public void setSalary(double salary) {
    this.salary = salary;
}

}

public class PermanentEmployee extends Employee {

private boolean pf = true;
private double salary;
private double tax;

public boolean isPf() {
    return pf;
}

public void setPf(boolean pf) {
    this.pf = pf;
}

public double getSalary() {
    salary = salary + (salary * 0.1);
    return salary;
}

public void setSalary(double salary) {
    this.salary = salary;
}

public double getTax() {
    tax = salary * 0.2;
    return tax;
}

public void setTax(double tax) {
    this.tax = tax;
}

}

public class TemporaryEmployee extends Employee {

private boolean pf = false;
private double tax;

public boolean isPf() {
    return pf;
}

public void setPf(boolean pf) {
    this.pf = pf;
}

public double getTax() {
    tax = salary * 0.15;
    return tax;
}

public void setTax(double tax) {
    this.tax = tax;
}

}

employee

@RakenShahi
Copy link

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeimplementation;

/**
*

  • @author DELL
    */
    public class EmployeImplementation {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      TemporaryEmployee t = new TemporaryEmployee();

      t.setName("Ravi");
      t.setSalary(35000);
      t.setPf(false);
      t.setDepartment("Civil");
      t.setTax2(500);
      System.out.println("Temporary :\nName : " + t.getName() + "\nDepartment : " + t.getDepartment() + "\nPf : " + t.isPf() + "\nSalary : " + (t.getSalary()) + "\nTax : " + (t.getTax2() * .15 + t.getTax2()));

      PermanentEmployee p = new PermanentEmployee();
      p.setName("Ganesh");
      p.setSalary(35000);
      p.setPf(true);
      p.setDepartment("Computer");
      p.setTax1(500);
      System.out.println("\nPermanent :\nName : " + p.getName() + "\nDepartment : " + p.getDepartment() + "\nPf : " + p.isPf() + "\nSalary : " + (p.getSalary() * 0.1 + p.getSalary()) + "\nTax : " + (p.getTax1() * .20 + p.getTax1()));

    }

}

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeimplementation;

/**
*

  • @author DELL
    */
    public class Employee {

    String name;
    String department;
    int salary;

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getDepartment() {
    return department;
    }

    public void setDepartment(String department) {
    this.department = department;
    }

    public int getSalary() {
    return salary;
    }

    public void setSalary(int salary) {
    this.salary = salary;
    }

}

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeimplementation;

/**
*

  • @author DELL
    */
    public class PermanentEmployee extends Employee {

    private boolean pf;
    private double sal;
    private double tax1;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public double getSal() {
    return (sal);
    }

    public void setSal(double sal) {
    this.sal = sal;

    }

    public double getTax1() {
    return tax1;
    }

    public void setTax1(double tax1) {
    this.tax1 = tax1;
    }
    }

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeimplementation;

/**
*

  • @author DELL
    */
    public class TemporaryEmployee extends Employee {

    private boolean pf;
    private int tax2;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public int getTax2() {
    return tax2;
    }

    public void setTax2(int tax2) {
    this.tax2 = tax2;
    }
    }

OUTPUT
employee

@maheshyakami
Copy link

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeeimplementaion;

import java.util.Scanner;

/**
*

  • @author mahesh
    */
    public class EmployeeImplementaion {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      PermanentEmployee p1 = new PermanentEmployee();
      TemporaryEmployee t1 = new TemporaryEmployee();
      Scanner ip = new Scanner(System.in);
      System.out.println("Enter Details of Permanent Employee");
      System.out.println("Name = ");
      p1.setName(ip.nextLine());
      System.out.println("Department = ");
      p1.setDept(ip.nextLine());
      System.out.println("Salary (€) = ");
      p1.setSal(ip.nextDouble());
      System.out.println("");
      System.out.println("Enter Details of Temporary Employee");
      System.out.println("Name = ");
      t1.setName(ip.nextLine());
      t1.setName(ip.nextLine());
      System.out.println("Department = ");
      t1.setDept(ip.nextLine());
      System.out.println("Salary (€) = ");
      t1.setSal(ip.nextDouble());

      System.out.println("Details of Permanent Employee:");
      System.out.println("Name: " + p1.getName() + "\tDepartment: " + p1.getDept() + "\nSalary: €" + p1.getSal() + "\tProvident Fund Availablity: " + p1.pf + "\nTotal Salary: €" + p1.newsal() + "\tTax Amount: €" + p1.tax());
      System.out.println();
      System.out.println("Details of Temporary Employee:");
      System.out.println("Name: " + t1.getName() + "\tDepartment: " + t1.getDept() + "\nTotal Salary: €" + t1.getSal() + "\tProvident Fund Availability: " + t1.pf + "\tTax Amount: €" + t1.tax());

    }

}
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeeimplementaion;

/**
*

  • @author mahesh
    */
    public class Employee {

    String Name, Dept;
    double sal;

    public void setName(String Name) {
    this.Name = Name;
    }

    public void setDept(String Dept) {
    this.Dept = Dept;
    }

    public void setSal(double sal) {
    this.sal = sal;
    }

    public String getName() {
    return Name;
    }

    public String getDept() {
    return Dept;
    }

    public double getSal() {
    return sal;
    }

}
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeeimplementaion;

/**
*

  • @author mahesh
    */
    public class PermanentEmployee extends Employee {

    boolean pf = true;

    double newsal() {
    sal = sal * 1.1;
    return sal;
    }

    double tax() {
    double tax = sal * .20;
    return tax;
    }
    }
    /*

  • To change this license header, choose License Headers in Project Properties.

  • To change this template file, choose Tools | Templates

  • and open the template in the editor.
    */
    package employeeimplementaion;

/**
*

  • @author mahesh
    */
    public class TemporaryEmployee extends Employee {

    boolean pf = false;

    double tax() {
    double tax = sal * .15;
    return tax;
    }

}

screen shot 2017-08-14 at 12 02 05 pm

@ghost
Copy link

ghost commented Aug 14, 2017

# Project: EmployeeImplementation
package employeeimplementation;

/**
*

  • @author User
    */
    public class EmployeeImplementation {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      PermanentEmp p = new PermanentEmp();
      p.setName("Alice");
      p.setPf(true);
      p.setDept("Computer");
      p.setInc(0.1f);
      p.setTax(0.2f);
      p.setSalary(35000);

      System.out.println("Name=" + p.getName());
      System.out.println("Provident Fund=" + p.isPf());
      System.out.println("Department=" + p.getDept());
      System.out.println("Increment Value=" + p.getInc());
      System.out.println("Tax=" + p.getTax());
      System.out.println("Salary=Rs" + (p.getSalary() + (p.getSalary() * p.getInc()) - (p.getSalary() * p.getTax())));
      System.out.println(" ");

      TemporaryEmp t = new TemporaryEmp();
      t.setName("Bob");
      t.setPf(false);
      t.setDept("Computer");
      t.setTax(0.15f);
      t.setSalary(35000);

      System.out.println("Name=" + t.getName());
      System.out.println("Provident Fund=" + t.isPf());
      System.out.println("Department=" + t.getDept());
      System.out.println("Tax=" + t.getTax());
      System.out.println("Salary=Rs" + (t.getSalary() - (t.getSalary() * t.getTax())));
      }
      }

# Class:Employee
public class Employee {

float salary;
private String dept;
private String name;

public float getSalary() {
    return salary;
}
public void setSalary(float salary) {
    this.salary = salary;
}
public String getDept() {
    return dept;
}
public void setDept(String dept) {
    this.dept = dept;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}

}

# Class:PermanentEmp
public class PermanentEmp extends Employee {

private boolean pf;
private float inc;
private float tax;

public boolean isPf() {
    return pf;
}

public void setPf(boolean pf) {
    this.pf = pf;
}

public float getInc() {
    return inc;
}

public void setInc(float inc) {
    this.inc = inc;
}

public float getTax() {
    return tax;
}

public void setTax(float tax) {
    this.tax = tax;
}

}
# Class:TemporaryEmp
public class TemporaryEmp extends Employee {

private boolean pf;
private float tax;

public boolean isPf() {
    return pf;
}

public void setPf(boolean pf) {
    this.pf = pf;
}

public float getTax() {
    return tax;
}

public void setTax(float tax) {
    this.tax = tax;
}

}
Output:
emplo

@syslin
Copy link

syslin commented Aug 14, 2017

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package inheritancetaskemployee;

/**
*

  • @author dell
    */
    public class InheritanceTaskEMployee {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {

      // TODO code application logic here
      PermanemtEmployee E1 = new PermanemtEmployee();
      E1.setName("Sanima");
      E1.setDept("Manager");
      E1.setPf(true);
      E1.setSalary(35000);
      System.out.println("Name of Permanent Employee:" + E1.getName());
      System.out.println("Department: " + E1.getDept());
      System.out.println("Pf: " + E1.isPf());
      System.out.println("Salary :" + E1.getSalary());
      System.out.println("tax :" + E1.getTax());

      // temporary employee
      TemporaryEmployee E2 = new TemporaryEmployee();
      E2.setName("Syslin");
      E2.setDept("Computer");
      E2.setPf(false);
      E2.setSalary(5000);
      System.out.println("Name of Temporary Employee:" + E2.getName());
      System.out.println("Department: " + E2.getDept());
      System.out.println("Pf: " + E2.isPf());
      System.out.println("Salary :" + E2.getSalary());
      System.out.println("tax :" + E2.getTax());

    }

}
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package inheritancetaskemployee;

/**
*

  • @author dell
    */
    public class EmployeeDetails {

    private String name;
    private String dept;
    float Salary;

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getDept() {
    return dept;
    }

    public void setDept(String dept) {
    this.dept = dept;
    }

    public float getSalary() {
    return Salary;
    }

    public void setSalary(float Salary) {
    this.Salary = Salary;
    }

}
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package inheritancetaskemployee;

/**
*

  • @author dell
    */
    public class PermanemtEmployee extends EmployeeDetails {

    private boolean pf = true;
    private float Salary;
    private float tax;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public float getSalary() {
    return Salary = (float) (Salary + (Salary * 0.1));
    }

    public void setSalary(float Salary) {
    this.Salary = Salary;
    }

    public float getTax() {
    return tax = (float) (Salary * 0.2);
    }

    public void setTax(float tax) {
    this.tax = tax;
    }

}
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package inheritancetaskemployee;

/**
*

  • @author dell
    */
    public class TemporaryEmployee extends EmployeeDetails {

    private boolean pf = false;
    private float tax;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public float getTax() {
    return tax = (float) (Salary * 0.15);
    }

    public void setTax(float tax) {
    this.tax = tax;
    }

}
e

@Sudan15423
Copy link

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package day11task;

/**
*

  • @author dragon15423
    */
    public class Day11Task {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      PermanentEmployee n = new PermanentEmployee();
      n.setName("ganesh");
      n.setSalary(35000);
      System.out.println("Name of employee: " + n.getName());
      float a = n.getSalary() * (1 + n.getSalary1()), b = a * n.getTax();
      System.out.println("Salary: " + a);
      System.out.println("Salary after tax: " + (a - b));
      System.out.println();

      TemporaryEmployee n1 = new TemporaryEmployee();
      n1.setName("ravi");
      n1.setSalary(35000);
      System.out.println("Name of employee: " + n1.getName());
      System.out.println("Salary after tax: " + n.getSalary() * (1 - n1.getTax()));
      System.out.println();
      }

}

Class Employee

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package day11task;

/**
*

  • @author dragon15423
    */
    public class Employee {

    private String name;
    private String department;
    private float salary;

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getDepartment() {
    return department;
    }

    public void setDepartment(String department) {
    this.department = department;
    }

    public float getSalary() {
    return salary;
    }

    public void setSalary(int salary) {
    this.salary = salary;
    }

}

Class PermanentEmployee

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package day11task;

/**
*

  • @author dragon15423
    */
    public class PermanentEmployee extends Employee {

    private boolean pf = true;
    private float salary1 = 0.1f;
    private float tax = 0.2f;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public float getSalary1() {
    return salary1;
    }

    public void setSalary1(int salary1) {
    this.salary1 = salary1;
    }

    public float getTax() {
    return tax;
    }

    public void setTax(int tax) {
    this.tax = tax;
    }

}

Class TemporaryEmployee

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package day11task;

/**
*

  • @author dragon15423
    */
    public class TemporaryEmployee extends Employee {

    private boolean pf = false;
    private float tax = 0.15f;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public float getTax() {
    return tax;
    }

    public void setTax(int tax) {
    this.tax = tax;
    }

}
day11task

@rivab
Copy link

rivab commented Aug 14, 2017

package day11task3;

/**
*

  • @author DELL
    */
    public class Day11Task3 {

    /**

    • @param args the command line arguments
      */
      public static void pfund(boolean pf) {
      if (pf == true) {
      System.out.println("Provident fund is provided\n");
      } else {
      System.out.println("Provident fund is not provided\n");
      }
      }

    public static void main(String[] args) {
    // TODO code application logic here
    double ptotal, ttotal;
    ParmanentEmployee p = new ParmanentEmployee();
    p.setName("Ramesh");
    p.setSalary(35000);
    p.setDept("Manager");
    ptotal = p.getSalary() * (1 + p.getSal() - p.getTax());
    System.out.println("Name:" + p.getName() + "\nDept:" + p.getDept() + "\nTotal salary:" + ptotal);
    pfund(p.isPf());

     TemproraryEmployee t = new TemproraryEmployee();
     t.setName("Suresh");
     t.setSalary(35000);
     t.setDept("Assistant");
     ttotal = t.getSalary() * (1 - t.getTax());
     System.out.println("Name:" + t.getName() + "\nDept:" + t.getDept() + "\nTotal salary:" + ttotal);
     pfund(t.isPf());
    

    }

}

public class Emloyee {

private String name;
private String dept;
private float salary;

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getDept() {
    return dept;
}

public void setDept(String dept) {
    this.dept = dept;
}

public float getSalary() {
    return salary;
}

public void setSalary(float salary) {
    this.salary = salary;
}

}

public class ParmanentEmployee extends Emloyee {

private boolean pf = true;
private float sal = 0.1f;
private float tax = 0.2f;

public float getSal() {
    return sal;
}

public void setSal(float sal) {
    this.sal = sal;
}

public float getTax() {
    return tax;
}

public void setTax(float tax) {
    this.tax = tax;
}

public boolean isPf() {
    return pf;
}

public void setPf(boolean pf) {
    this.pf = pf;
}

}

public class TemproraryEmployee extends Emloyee {

private boolean pf = false;
private float tax = 0.15f;

public float getTax() {
    return tax;
}

public void setTax(float tax) {
    this.tax = tax;
}

public Boolean getPf() {
    return pf;
}

public void setPf(Boolean pf) {
    this.pf = pf;
}

public boolean isPf() {
    return pf;
}

public void setPf(boolean pf) {
    this.pf = pf;
}

}
day11task3

@sthaanu
Copy link

sthaanu commented Aug 15, 2017

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeeimplementation1;

/**
*

  • @author admin
    */
    public class EmployeeImplementation1 {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      PermanentEmployee e = new PermanentEmployee();
      e.setName("Anu");
      e.setSalary(35000);
      e.setDepartment("Computer");
      e.setPf(true);
      e.setSal(0.1);
      e.setTax(0.2);

      double SalInc = (e.getSal() * e.getSalary());
      double TaxAdd = (e.getTax() * SalInc);
      double total = (e.getSalary() + SalInc - TaxAdd);

      System.out.println("Permanent Employees:");
      System.out.println("Name:" + e.getName());
      System.out.println("Department:" + e.getDepartment());
      System.out.println("Pf:" + e.getPf());
      System.out.println("Salary:" + e.getSalary());
      System.out.println("Incremented Salary:" + SalInc);
      System.out.println("Tax :" + TaxAdd);
      System.out.println("Total Salary:" + total);

      TemporaryEmployee emp = new TemporaryEmployee();

      emp.setName("Ram");
      emp.setSalary(35000);
      emp.setDepartment("Computer");
      emp.setPf(false);
      emp.setTax(0.15);

      double TotalTemp = (emp.getSalary() - emp.getTax() * emp.getSalary());
      System.out.println("");
      System.out.println("Temporary Employee:");
      System.out.println("Name:" + emp.getName());
      System.out.println("Department:" + emp.getDepartment());
      System.out.println("Pf:" + emp.getPf());
      System.out.println(" Salary:" + emp.getSalary());
      System.out.println("Total Salary:" + TotalTemp);

    }

}
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeeimplementation1;

/**
*

  • @author admin
    */
    public class Employee {

    private String name;
    private String Department;
    private double salary;

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getDepartment() {
    return Department;
    }

    public void setDepartment(String Department) {
    this.Department = Department;
    }

    public double getSalary() {
    return salary;
    }

    public void setSalary(double salary) {
    this.salary = salary;
    }

}
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeeimplementation1;

/**
*

  • @author admin
    */
    public class PermanentEmployee extends Employee {

    private Boolean Pf = true;
    private double salary;
    private double Sal;
    private double tax;

    public Boolean getPf() {
    return Pf;
    }

    public void setPf(Boolean Pf) {
    this.Pf = Pf;
    }

    public double getSalary() {
    return salary;
    }

    public void setSalary(int salary) {
    this.salary = salary;
    }

    public double getSal() {
    return Sal;
    }

    public void setSal(double Sal) {
    this.Sal = Sal;
    }

    public double getTax() {
    return tax;
    }

    public void setTax(double tax) {
    this.tax = tax;
    }

}
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package employeeimplementation1;

/**
*

  • @author admin
    */
    public class TemporaryEmployee extends Employee {

    private Boolean Pf = false;
    private double tax;

    public Boolean getPf() {
    return Pf;
    }

    public void setPf(Boolean Pf) {
    this.Pf = Pf;
    }

    public double getTax() {
    return tax;
    }

    public void setTax(double tax) {
    this.tax = tax;
    }

}
capture

@sajanbasnet75
Copy link

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package classemp;

/**
*

  • @author LORDsajan
    */
    public class Employee {

    private String name;
    private String dept;
    private double salary;

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getDept() {
    return dept;
    }

    public void setDept(String dept) {
    this.dept = dept;
    }

    public double getSalary() {
    return salary;
    }

    public void setSalary(double salary) {
    this.salary = salary;
    }
    }

Class PermanentEmployee
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package classemp;

/**
*

  • @author LORDsajan
    */
    public class PermanentEmployee extends Employee {

    private boolean pf = true;
    private float sal = 0.1f;
    private float tax = 0.2f;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public float getSal() {
    return sal;
    }

    public void setSal(float sal) {
    this.sal = sal;
    }

    public float getTax() {
    return tax;
    }

    public void setTax(float tax) {
    this.tax = tax;
    }

}

Class TemporaryEmployee
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package classemp;

/**
*

  • @author LORDsajan
    */
    public class TemporaryEmployee extends Employee {

    private boolean pf = false;
    private float tax = 0.15f;

    public boolean isPf() {
    return pf;
    }

    public void setPf(boolean pf) {
    this.pf = pf;
    }

    public float getTax() {
    return tax;
    }

    public void setTax(float tax) {
    this.tax = tax;
    }
    }
    em

@ErSKS ErSKS closed this as completed Aug 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests