FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/emp.java at main · VirajPatidar/Java-Programs · GitHub
VirajPatidar
/
Java-Programs
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs
/
emp.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (49 loc) · 1.59 KB
Breadcrumbs
Java-Programs
/
emp.java
Copy path
File metadata and controls
49 lines (49 loc) · 1.59 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
java
.
util
.
Scanner
;
public
class
emp
{
static
Scanner
sc
=
new
Scanner
(
System
.
in
);
String
name
;
String
dept
;
int
age
;
void
read
() {
System
.
out
.
println
(
"Enter employee Name, department and age in order"
);
name
=
sc
.
nextLine
();
dept
=
sc
.
nextLine
();
age
=
Integer
.
parseInt
(
sc
.
nextLine
());
}
void
display
(){
System
.
out
.
println
(
"Name: "
+
name
+
" Department: "
+
dept
+
" Age: "
+
age
);
}
void
compare
(
emp
e1
,
emp
e2
) {
int
count
=
0
;
if
(
e1
.
name
.
equals
(
e2
.
name
)){
System
.
out
.
println
(
"Employee name is same"
);
count
++;
}
if
(
e1
.
dept
.
equals
(
e2
.
dept
)){
System
.
out
.
println
(
"Employee dept is same"
);
count
++;
}
if
(
e1
.
age
==
e2
.
age
){
System
.
out
.
println
(
"Employee age is same"
);
count
++;
}
if
(
count
==
3
)
System
.
out
.
println
(
"Employee data of "
+
e1
.
name
+
" is entered twice"
);
}
public
static
void
main
(
String
[]
args
) {
System
.
out
.
println
(
"Enter the number of employees"
);
int
n
=
Integer
.
parseInt
(
sc
.
nextLine
());
emp
e
[] =
new
emp
[
n
];
emp
obj
=
new
emp
();
for
(
int
i
=
0
;
i
<
e
.
length
;
i
++) {
e
[
i
] =
new
emp
();
e
[
i
].
read
();
}
System
.
out
.
println
(
"
\n
Enter the indexes of two employees to compare"
);
int
a
=
Integer
.
parseInt
(
sc
.
nextLine
());
int
b
=
Integer
.
parseInt
(
sc
.
nextLine
());
obj
.
compare
(
e
[
a
],
e
[
b
]);
System
.
out
.
println
(
"
\n
"
);
for
(
int
i
=
0
;
i
<
e
.
length
;
i
++)
e
[
i
].
display
();
}
}
Back
|
FazBrowse Home
|
New Git URL