-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathUni.java
More file actions
77 lines (61 loc) · 1.79 KB
/
Uni.java
File metadata and controls
77 lines (61 loc) · 1.79 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import java.util.*;
class Vorodi implements Comparable<Vorodi> {
private String name;
private int code;
private double moadel;
public void setName(String n) {
this.name = n;
}
public String getName() {
return name;
}
public void setCode(int c) {
this.code = c;
}
public int getCode() {
return code;
}
public void setMoadel(double m) {
this.moadel = m;
}
public double getMoadel() {
return moadel;
}
public int compareTo(Vorodi other) {
return Integer.compare(this.code, other.code);
}
public Vorodi(String n, int c, double m) {
setName(n);
setCode(c);
setMoadel(m);
}
public String d() {
return ("[" + getName() + "," + getCode() + "," + getMoadel() + "]");
}
}
public class Uni {
public static void main(String[]args) {
TreeSet<Vorodi> studentSet = new TreeSet<>();
Scanner s = new Scanner(System.in);
int tedad = s.nextInt();
for (int i = 0; i < tedad; i++) {
String n = s.next();
int c = s.nextInt();
double m = s.nextDouble();
Vorodi student = new Vorodi(n, c, m);
studentSet.add(student);
}
int searchId = s.nextInt();
boolean found = false;
for (Vorodi i : studentSet) {
if (searchId == i.getCode()) {
System.out.println("Student Found");
System.out.println("name :" + i.getName() + "\nId : " + i.getCode() + "\nmoadel :" + i.getMoadel());
found = true;
}
}
if (!found) {
System.out.println("Student not Found");
}
}
}