-
Notifications
You must be signed in to change notification settings - Fork 0
/
inheritance.java
179 lines (178 loc) · 4.03 KB
/
inheritance.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
class Employee
{
String emp_name,address,mail_id;
int emp_id;
long mob_no;
void details() throws Exception
{
DataInputStream d=new DataInputStream(System.in);
System.out.print("Enter the name:");
emp_name=(d.readLine());
System.out.print("Enter the address:");
address=(d.readLine());
System.out.print("Enter the mail address:");
mail_id=(d.readLine());
System.out.print("Enter the employee id:");
emp_id=Integer.parseInt(d.readLine());
System.out.print("Enter the mobile number:");
mob_id=Long.parseLong(d.readLine());
}
void display()
{
System.out.println(emp_name);
System.out.println(address);
System.out.println(mail_id);
System.out.println(emp_id);
System.out.println(mobile_no);
System.out.println("End of Employee class");
}
}
class Programmer extends Employee
{
int BP;
float DA,HRA,PF,SCF,net_salary,gross_salary
void input() throws Exception
{
details();
DataInputStream d=new DataInputStream(System.in);
System.out.print("Enter the Basic Pay:");
BP=Integer.parseInt(d.readLine());
}
void calculation()
{
DA=0.97f*BP;
HRA=0.10f*BP;
PF=0.12f*BP;
SCF=0.001f*BP;
gross_salary=BP+DA;
net_salary=gross_salary-PF_SCF;
}
void output()
{
System.out.println("DA:"+DA);
System.out.println("HRA:"+HRA);
System.out.println("PF:"+PF);
System.out.println("SCF:"+SCF);
System.out.println("GROSS SALARY:"+gross_salary);
System.out.println("NET SALARY:"+net_salary);
System.out.println("End of Programmer class");
}
}
class Assistant_professor extends Employee
{
int BP;
float DA,HRA,PF,SCF,net_salary,gross_salary
void inp() throws Exception
{
details();
DataInputStream d=new DataInputStream(System.in);
System.out.print("Enter the Basic Pay:");
BP=Integer.parseInt(d.readLine());
}
void cal()
{
DA=0.97f*BP;
HRA=0.10f*BP;
PF=0.12f*BP;
SCF=0.001f*BP;
gross_salary=BP+DA;
net_salary=gross_salary-PF_SCF;
}
void disp()
{
System.out.println("DA:"+DA);
System.out.println("HRA:"+HRA);
System.out.println("PF:"+PF);
System.out.println("SCF:"+SCF);
System.out.println("GROSS SALARY:"+gross_salary);
System.out.println("NET SALARY:"+net_salary);
System.out.println("End of Assistant professor class");
}
}
class Associate_professor extends Employee
{
int BP;
float DA,HRA,PF,SCF,net_salary,gross_salary
void get() throws Exception
{
details();
DataInputStream d=new DataInputStream(System.in);
System.out.print("Enter the Basic Pay:");
BP=Integer.parseInt(d.readLine());
}
void logic()
{
DA=0.97f*BP;
HRA=0.10f*BP;
PF=0.12f*BP;
SCF=0.001f*BP;
gross_salary=BP+DA;
net_salary=gross_salary-PF_SCF;
}
void show()
{
System.out.println("DA:"+DA);
System.out.println("HRA:"+HRA);
System.out.println("PF:"+PF);
System.out.println("SCF:"+SCF);
System.out.println("GROSS SALARY:"+gross_salary);
System.out.println("NET SALARY:"+net_salary);
System.out.println("End of Associate professor class");
}
}
class Professor extends Employee
{
int BP;
float DA,HRA,PF,SCF,net_salary,gross_salary
void read() throws Exception
{
details();
DataInputStream d=new DataInputStream(System.in);
System.out.print("Enter the Basic Pay:");
BP=Integer.parseInt(d.readLine());
}
void find()
{
DA=0.97f*BP;
HRA=0.10f*BP;
PF=0.12f*BP;
SCF=0.001f*BP;
gross_salary=BP+DA;
net_salary=gross_salary-PF_SCF;
}
void print()
{
System.out.println("DA:"+DA);
System.out.println("HRA:"+HRA);
System.out.println("PF:"+PF);
System.out.println("SCF:"+SCF);
System.out.println("GROSS SALARY:"+gross_salary);
System.out.println("NET SALARY:"+net_salary);
System.out.println("End of Professor class");
}
}
class result
{
public static void main(String a[]) throws Exception
{
Employee p=new Employee();
p.details();
p.display();
Programmer q=new Programmer();
q.input();
q.calculation();
q.output();
Assistant_professor r=new Assistant_professor();
r.inp();
r.cal();
r.disp();
Associate_professor s=new Associate_professor();
s.get();
s.logic();
s.show();
Professor t=new Professor();
t.read();
t.find();
t.print();
}
}