-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmp_Salary.java
52 lines (51 loc) · 1.04 KB
/
Emp_Salary.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
//Single Inheritance, without constructor
import java.util.*;
class Employee
{
String name;
int id;
double basic;
void getdata()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Employee name,Employee ID and basic pay. ");
name = sc.nextLine();
id = sc.nextInt();
basic = sc.nextDouble();
}
void display1()
{
System.out.println("Name = "+name);
System.out.println("ID = "+id);
System.out.println("Basic Pay = "+basic);
}
}
class Salary extends Employee
{
double DA, HRA, PF = 1200, GP, NP;
void calculate()
{
DA = basic * 0.10;
HRA = basic * 0.05;
GP = basic + DA + HRA;
NP = GP - PF;
}
void display2()
{
System.out.println("Dearness Allowance = "+DA);
System.out.println("House Rent Allowance = "+HRA);
System.out.println("Gross Pay = "+GP);
System.out.println("Net Pay = "+NP);
}
}
class Emp_Salary
{
public static void main(String args[])
{
Salary s = new Salary();
s.getdata();
s.display1();
s.calculate();
s.display2();
}
}