Skip to content

Commit 23bd339

Browse files
authored
Create Question
1 parent e71eead commit 23bd339

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

Question

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Question :
2+
3+
Create a class called Employee with the below attributes:
4+
employeeld - int
5+
name - String
6+
branch - String
7+
rating - double
8+
company Transport - boolean
9+
The above attributes should be private. write getters, setters and parameterized constructor as required.
10+
11+
Create class MyClass with main method.
12+
Implement two static methods findCountOfEmployeesUsingCompTransport and findEmployeeWithSecondHighestRating in MyClass class.
13+
14+
findCountOfEmployeesUsingCompTransport method:
15+
This method will take an array of Employee object and a String parameter as input parameters. This method will calculate and return the count of Employees who are all using company transport in the given branch (String parameter passed).
16+
If no Employee in the given branch using company transport in the array of Employee objects, then the method should return 0.
17+
18+
findEmployeeWithSecondHighestRating method:
19+
This method will take an array of Employee objects as an input parameter. This method will return the object of the second highest rating employee from the array of Employee objects who are not using company transport.
20+
If all Employees using company transport in the array of Employee objects, then the method should return null.
21+
22+
Note: All the searches should be case sensitive, companyTransport and rating combination of each Employee is unique.
23+
For findCountOfEmployeesUsingCompTransport method, The main method should print the returned count as it is if the returned value is greater than 0, else it should print "No such Employees".
24+
Ex: 2 , where 2 is the count
25+
For findEmployeeWithSecondHighestRating method: The main method should print the employeeld and name from the returned object if the returned value is not null. If the returned value is null, then it should print "All Employees using company transport".
26+
Ex: 1003
27+
Uma
28+
where 1003 is the employeeld and Uma is the name.
29+
Before calling these static methods in main, use Scanner object to read the values of four Employee objects referring attributes in the above mentioned attributes sequence. Next, read the value of String parameter for capturing branch.
30+
31+
Input :
32+
33+
1001
34+
Ashwa
35+
IT
36+
5
37+
true
38+
1002
39+
Preeti
40+
IT
41+
4
42+
true
43+
1003
44+
Uma
45+
Admin
46+
3
47+
false
48+
1004
49+
Akash
50+
Hardware
51+
4.5
52+
false
53+
IT
54+
55+
56+
57+
Output :
58+
59+
2
60+
1003
61+
Uma
62+

0 commit comments

Comments
 (0)