-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee_My_Practice.java
More file actions
53 lines (49 loc) · 1.38 KB
/
Employee_My_Practice.java
File metadata and controls
53 lines (49 loc) · 1.38 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
import java.util.Scanner;
public class Employee {
public int eid;
public String ename;
public int emp_sal;
public String c_name;
public Employee(int id, int sal, String name, String cname)
{
eid = id;
ename = name;
emp_sal = sal;
c_name = cname;
}
public void result(Employee arr[]){
int x = 0;
int y = 0;
for (int i =0; i<arr.length;i++){
if (arr[i].c_name.equals("A")){
if (arr[i].emp_sal>x){
x = arr[i].emp_sal;
}
}
else
{
if(arr[i].emp_sal>y)
{
y = arr[i].emp_sal;
}
}
}
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int a = s.nextInt();
Employee arr1[] = new Employee[a];
for (int j=0;j< arr1.length;j++)
{
arr1[j] = new Employee(id = s.nextInt(), name = s.next(), sal = s.nextInt(), cname = s.next() );
}
for (int k=0;k< arr1.length;k++){
if (arr1[k].emp_sal.equals(x)){
System.out.println(Employee.result(arr1[k]));
}
if (arr1[k].emp_sal.equals(y)){
System.out.println(Employee.result(arr1[k]));
}
}
}
}