-
Notifications
You must be signed in to change notification settings - Fork 1
/
Assignment3.java
207 lines (202 loc) · 5.84 KB
/
Assignment3.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
package Employee;
import java.util.*;
class Driver{
String Emp_name, Address, MailID , mobile_no ;
double Basicpay, DA , HRA ,PF , SCF ;
int emp_id ;
public static int count = 0;
boolean mail() {
return MailID.endsWith("@gmail.com");
}
boolean mob_no() {
return (mobile_no.length() == 10 && mobile_no.charAt(0) != '0');
}
public void getData() {
Scanner sc = new Scanner( System.in );
System.out.println("Enter your name :- ");
Emp_name = sc.next();
System.out.println("Enter your Address :- ");
Address = sc.next();
System.out.println("Enter your Employee ID :- ");
emp_id = sc.nextInt();
do {
System.out.println( "Enter your Email id ");
MailID = sc.next();
if( mail() ) break;
else {
System.out.println("Please enter valid email id , RETRY !!!");
}
}while(true);
do {
System.out.println( "Enter Mobile Number ");
mobile_no = sc.next();
if( mob_no() ) break;
else {
System.out.println("Please enter valid mobile number , RETRY !!!");
}
}while(true);
}
double gross;
double net;
void gross(double Basicpay) {
this.Basicpay = Basicpay;
DA = 0.97 * Basicpay;
HRA = 0.10 * Basicpay;
PF = 0.12 * Basicpay;
SCF = 0.001 * Basicpay;
gross = Basicpay + DA + HRA + PF + SCF;
net = Basicpay + DA + HRA - PF + SCF;
}
void getSalary() {
System.out.println("Your Basic Pay is:-" + Emp_name );
System.out.println("Your Basic Pay is:-" + Basicpay);
System.out.println("Your DA is:-" + DA);
System.out.println("Your HRA is:-" + HRA);
System.out.println("Your PF is:-" + PF);
System.out.println("Your SCF is:-"+ SCF);
System.out.println("Your Gross salary is:-" + gross);
System.out.println("Your Net Salary is:-" + net);
}
}
class Programmer extends Driver{
public static int count = 0;
double basic_pay;
Scanner sc = new Scanner(System.in);
double getPay() {
System.out.println("Enter the basic pay of the programmer");
basic_pay = sc.nextDouble();
return basic_pay;
}
}
class Teamlead extends Driver{
public static int count = 0;
double basic_pay;
Scanner sc = new Scanner(System.in);
double getPay() {
System.out.println("Enter the basic pay of the Team Lead");
basic_pay = sc.nextDouble();
return basic_pay;
}
}
class AssistantProject extends Driver{
public static int count = 0;
double basic_pay;
Scanner sc = new Scanner(System.in);
double getPay() {
System.out.println("Enter the basic pay of the Assistant project manager");
basic_pay = sc.nextDouble();
return basic_pay;
}
}
class ProjectManager extends Driver{
public static int count = 0;
double basic_pay;
Scanner sc = new Scanner(System.in);
double getPay() {
System.out.println("Enter the basic pay of the ProjectManager");
basic_pay = sc.nextDouble();
return basic_pay;
}
}
public class Employee {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int choice;
int n;
System.out.println("Enter the no. of employee you want to print = ");
n = sc.nextInt();
Programmer p[] = new Programmer[n];
Teamlead t[] = new Teamlead[n];
AssistantProject a[] = new AssistantProject[n];
ProjectManager m[] = new ProjectManager[n];
do {
System.out.println("1.Display the salary of the Programmer");
System.out.println("2.Display the salary of the Team lead");
System.out.println("3.Display the salary of the Assistant Project Manager");
System.out.println("4.Display the salary of the Project Manager");
System.out.println("5.Exit");
choice = sc.nextInt();
switch( choice ) {
case 1:
int n1;
System.out.println("Enter the number of Programmer data you want to feed=");
n1 = sc.nextInt();
n1 = n1 + Programmer.count;
for( int i = Programmer.count ;i < n1 ; i++ ) {
p[i] = new Programmer();
p[i].getData();
double basic1 = p[i].getPay();
p[i].gross(basic1);
Driver.count++;
Programmer.count++;
}
for( int i = 0 ; i < n1 ; i++ ) {
System.out.println("******************************PAY SLIP***********************************");
p[i].getSalary();
}
n--;
break;
case 2:
int n2;
System.out.println("Enter the number of team lead data you want to feed=");
n2 = sc.nextInt();
n2 = n2 + Teamlead.count;
for( int i = Teamlead.count ;i < n2 ; i++ ) {
t[i] = new Teamlead();
t[i].getData();
double basic1 = t[i].getPay();
t[i].gross(basic1);
Driver.count++;
Teamlead.count++;
}
for( int i = 0 ; i < n2 ; i++ ) {
System.out.println("******************************PAY SLIP***********************************");
t[i].getSalary();
}
n--;
break;
case 3:
int n3;
System.out.println("Enter the number of Assistant Project Manager data you want to feed=");
n3 = sc.nextInt();
n3 = n3 + AssistantProject.count;
for( int i = AssistantProject.count ;i < n3 ; i++ ) {
a[i] = new AssistantProject();
a[i].getData();
double basic1 = a[i].getPay();
a[i].gross(basic1);
Driver.count++;
AssistantProject.count++;
}
for( int i = 0 ; i < n3 ; i++ ) {
System.out.println("******************************PAY SLIP***********************************");
a[i].getSalary();
}
n--;
break;
case 4:
int n4;
System.out.println("Enter the number of Project Manager data you want to feed=");
n4 = sc.nextInt();
n4 = n4 + ProjectManager.count;
for( int i = ProjectManager.count ;i < n4 ; i++ ) {
m[i] = new ProjectManager();
m[i].getData();
double basic1 = m[i].getPay();
m[i].gross(basic1);
Driver.count++;
ProjectManager.count++;
}
for( int i = 0 ; i < n4 ; i++ ) {
System.out.println("******************************PAY SLIP***********************************");
m[i].getSalary();
}
n--;
break;
case 5:
break;
}
}while(choice!= 5);
System.out.print("The total no. of employee data feeded" + "=" + Driver.count );
}
}