Assignment No 2 (Aniket Digge)
Assignment No 2 (Aniket Digge)
2
PQR & Company Ltd two kinds of employee, Permanent and Contractual .The Permanent
Employee has monthly salary and PF which is 15% of salary. Contractual employee has
contract period and contract amount. Every employee has id (for permanent ids are like
P1001,P1002... and for contractual ids are like C1001,C1002... etc.), name, dept-name. Id for
permanent will be in even number that of odd number for contractual employee. The input for
any employee is in comma(,) separate format eg:
Any type of employee needs to pay tax which is 10% of annual salary. You need to create
String employeeId,
String employeeName,
String department
Double monthlySalary,
Double tax,
override calculateTax()
Integer contractPeriod,
Double contarctAmount,
Double tax,
D) class Main with method public static void main(String [] arg)-> In this method
Ans:-
import java.util.Scanner;
class Employee{
public Employee(){}
this.employeeId = employeeId;
this.employeeName = employeeName;
this.department = department;
System.out.println("Employee ID = "+employeeId);
System.out.println("Department = "+department);
}
@Override
return super.toString();
public PermanentEmployee(){}
this.monthlySalary = monthlySalary;
pf = monthlySalary*0.15;
tax = monthlySalary*0.10;
}
public void setter(){
System.out.println("PF = "+pf);
System.out.println("TAX = "+tax);
@Override
return super.toString();
Double tax;
public ContractEmployee(){}
this.contarctAmount = contarctAmount;
this.contractPeriod = contractPeriod;
tax = contarctAmount*contractPeriod*0.10;
}
System.out.println("TAX = "+tax);
@Override
return super.toString();
String strid;
String strname;
String strdept;
strid = sc.nextLine();
strname = sc.nextLine();
strdept = sc.nextLine();
for (int i = 0; i < strid.length(); i++) {
if(i==4){
int n = strid.charAt(i);
if(n%2==0){
System.out.println();
System.out.println("Perment Employee.");
System.out.println("-----------------------------------");
System.out.println();
e.setter();
System.out.println();
pe.getter(sal);
pe.calculateTax();
pe.setter();
else{
System.out.println();
System.out.println("Contract Employee.");
System.out.println("-----------------------------------");
System.out.println();
System.out.println();
int pd = Integer.parseInt(sc.nextLine());
ce.getter(pd, amt);
ce.calculateTax();
ce.setter();
Output:-