forked from DHEERAJHARODE/Hacktoberfest2024-Open-source-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmployeeDetails.java
86 lines (82 loc) · 2.11 KB
/
EmployeeDetails.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import java.util.*;
abstract class EmployeeData
{
String EmpName,Empid;
EmployeeData()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter EmpName & Empid");
EmpName=sc.nextLine();
Empid=sc.nextLine();
}
}
interface EmployeeMethods
{
void getDetails();
void calculateSal();
void display();
}
class Employee extends EmployeeData implements EmployeeMethods
{ double DA,HRA,PF,LIC,Grosspay,Netpay,Basicpay;
String designation;
Employee()
{
int choice;
Scanner sc = new Scanner(System.in);
System.out.println("Enter choice\n1 for Manager\n2 for Scientist\n3 for Labour :");
choice=sc.nextInt();
switch(choice) {
case 1 :
designation= "Manager";
break;
case 2 :
designation= "Scientist";
break;
case 3 :
designation= "Labour";
break;
default :
System.out.println("Invalid Input");
}
}
public void getDetails()
{ Scanner sc = new Scanner(System.in);
System.out.println("Enter basic pay :");
Basicpay=sc.nextDouble();
System.out.println("Enter DA % :");
DA=sc.nextDouble();
System.out.println("Enter HRA % :");
HRA=sc.nextDouble();
System.out.println("Enter PF % :");
PF=sc.nextDouble();
System.out.println("Enter LIC % :");
LIC=sc.nextDouble();
}
public void calculateSal()
{
DA/=100;
HRA/=100;
PF/=100;
LIC/=100;
Grosspay=Basicpay+(DA*Basicpay)+(HRA*Basicpay);
Netpay=Grosspay-((PF*Basicpay)+(LIC*Basicpay));
}
public void display()
{
System.out.println("Employee Name\t:\t"+EmpName);
System.out.println("Employee Id\t:\t"+Empid);
System.out.println("Designation\t:\t"+designation);
System.out.println("Grosspay\t:\t"+Grosspay);
System.out.println("Net pay\t\t:\t"+Netpay);
}
}
class EmployeeDetails
{
public static void main(String[] args)
{
Employee obj=new Employee();
obj.getDetails();
obj.calculateSal();
obj.display();
}
}