You are on page 1of 2

12/19/2019 C:\Users\Mahi\Desktop\Associate.

java

1 import java.util.*;
2 class Associate {
3
4
5 private String asName;
6 private int asId;
7 private int asExp;
8 private String asTech;
9
10 public Associate(String asName, int asId,String asTech, int asExp ) {
11 this.asName = asName;
12 this.asId = asId;
13 this.asExp = asExp;
14 this.asTech = asTech;
15 }
16
17
18 public String getAsName() {
19 return asName;
20 }
21 public void setAsName(String asName) {
22 this.asName = asName;
23 }
24 public int getAsId() {
25 return asId;
26 }
27 public void setAsId(int asId) {
28 this.asId = asId;
29 }
30 public int getAsExp() {
31 return asExp;
32 }
33 public void setAsExp(int asExp) {
34 this.asExp = asExp;
35 }
36 public String getAsTech() {
37 return asTech;
38 }
39 public void setAsTech(String asTech) {
40 this.asTech = asTech;
41 }
42 }
43 class Solution {
44
45 public static Associate[] searchByTech(Associate [] ass, String tech){
46
47 Associate []temp = new Associate[5];
48 int j=0;
49 for(int i=0;i<5;i++){
50 if(ass[i].getAsExp() % 5 == 0 && ass[i].getAsTech().equalsIgnoreCase(tech)){
file:///C:/Users/Mahi/appdata/local/temp/tmpg0mzf7.html 1/2
12/19/2019 C:\Users\Mahi\Desktop\Associate.java
51 temp[j++]=ass[i];
52 }
53 }
54 return temp;
55
56 }
57 public static void main(String []args ) {
58 Scanner in = new Scanner(System.in);
59 Associate [] ass = new Associate[5];
60
61 for (int i =0;i<5;i++) {
62 String asName =in.nextLine();
63 int aId =in.nextInt();
64 in.nextLine();
65 String technology =in.nextLine();
66 int exp = in.nextInt();
67 in.nextLine();
68 ass[i] =new Associate(asName,aId,technology,exp);
69 }
70 String tech=in.nextLine();
71
72 Associate[] ass1 = searchByTech(ass,tech);
73
74 for(Associate a1 : ass1){
75 if(a1 != null)
76 System.out.println(a1.getAsId());
77 }
78
79 }
80
81
82
83
84
85
86
87 }

file:///C:/Users/Mahi/appdata/local/temp/tmpg0mzf7.html 2/2

You might also like