-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDay21_prob2.java
97 lines (78 loc) · 1.76 KB
/
Day21_prob2.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
/*
A set of employees Joins a new company and they started entering their details such as Name, Age, Experience, Employee-id, Salary. Then Once the HR enter their name he gets the complete details of the employees.
Input Format
Rahul
Constraints
Use Parameterized Constructor to initialize the data members
Use toString() method to display the details and getName() method to display the name
Output Format
Rahul
33
10
1132
30000
Sample Input 0
Rahul
Sample Output 0
Rahul
33
10
1132
30000
Sample Input 1
Ramesh
Sample Output 1
Ramesh
43
20
1133
40000
Sample Input 2
Ram
Sample Output 2
Ram
53
30
1134
60000
*/
// Kirtan Jain
import java.util.Scanner;
class Employee {
private String name;
private int age;
private int experience;
private int employeeId;
private int salary;
Employee(String name, int age, int experience, int employeeId, int salary) {
this.name = name;
this.age = age;
this.experience = experience;
this.employeeId = employeeId;
this.salary = salary;
}
String getName() {
return name;
}
@Override
public String toString() {
return name + "\n" + age + "\n" + experience + "\n" + employeeId + "\n" + salary;
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();
Employee[] employees = {
new Employee("Rahul", 33, 10, 1132, 30000),
new Employee("Ramesh", 43, 20, 1133, 40000),
new Employee("Ram", 53, 30, 1134, 60000),
};
for (Employee employee : employees) {
if (employee.getName().equals(name)) {
System.out.println(employee);
break;
}
}
}
}