-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathd4_salary_cal.java
More file actions
83 lines (77 loc) · 2.19 KB
/
d4_salary_cal.java
File metadata and controls
83 lines (77 loc) · 2.19 KB
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
// Salary Calculator
import java.util.Scanner;
class Employee
{
int id;
String name,post;
double basic_pay,da,hra,pf,gross_pay;
Employee(int eid,String ename,String epost)
{
id = eid;
name = ename;
post = epost;
if(post.equals("Manager"))
basic_pay = 30000.0;
else if(post.equals("Ast Manager"))
basic_pay = 25000.0;
else
basic_pay = 20000.0;
}
void calc()
{
if(post.equals("Manager"))
{
da = basic_pay * 0.30;
hra = basic_pay * 0.20;
pf = basic_pay * 0.20;
gross_pay = basic_pay + da + hra - pf;
}
else if(post.equals("Ast Manager"))
{
da = basic_pay * 0.20;
hra = basic_pay * 0.10;
pf = basic_pay * 0.10;
gross_pay = basic_pay + da + hra - pf;
}else{
da = basic_pay * 0.10;
hra = basic_pay * 0.05;
pf = basic_pay * 0.05;
gross_pay = basic_pay + da + hra - pf;
}
}
void display()
{
System.out.println("****Salary Statement****");
System.out.println("Employee name: " + name);
System.out.println("Employee id: " + id);
System.out.println("Employee role: " + post);
System.out.println("Basic Pay: " + basic_pay);
System.out.println("DA: " + da);
System.out.println("HRA: " + hra);
System.out.println("PF: " + pf);
System.out.println("Gross Pay: " + gross_pay);
System.out.println("****End Statement****");
}
}
class d4_salary_cal
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
System.out.print("Employee Name: ");
String ename = scan.nextLine();
System.out.print("Employee Role: ");
String epost = scan.nextLine();
System.out.print("Employee ID: ");
int eid = scan.nextInt();
Employee e1 = new Employee(eid,ename,epost);
e1.calc();
clearScreen();
e1.display();
}
public static void clearScreen()
{
System.out.print("\003[H\033[2J");
System.out.flush();
}
}