Question
Need Help writing a java program by using the java stream API as per the below requirements. Note: Please don't give other solutions other than
Need Help writing a java program by using the java stream API as per the below requirements.
Note: Please don't give other solutions other than which asked below requirements .
Create a class Employee having the following attributes in private scope: int id; String name; String department; double salary;
Create a class Solution having the main method and do the following from the main method.
Create a List of Employees by taking following inputs from user: 1. First read a value representing the number of Employees to be there in the list 2. Then for each employee, take the above set of attributes as input from user one after another. Create the Employee objects and add to the list
Do the following operations on the list using Stream APIs : Note : Do the operations and print outputs only in the order specified below. Otherwise test-cases may fail.
1. Print name of all employees (in separate lines) where the names start with H 2. Print names of all distinct departments (in separate lines) 3. Print count of employees from IT department 4. Print sum of salaries of all employees
Sample Input: ------------- 4 101 Harry IT 2000.5 201 Ron Finance 1000 301 Sirius IT 1000.5 401 Hagrid IT 4000
Expected Output : ----------------- Harry Hagrid IT Finance 3 8001.0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started