0% found this document useful (0 votes)
1 views

Lab 6 Programming Algorithms and Patterns

Uploaded by

Taina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Lab 6 Programming Algorithms and Patterns

Uploaded by

Taina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CEGEP VANIER COLLEGE

CENTRE FOR CONTINUING EDUCATION


Programming Algorithms and Patterns
420-930-VA

Teacher: Samir Chebbine Lab 6 Nov 29, 2024

Lab 6: Stream Processing

Complete all these following programs as explained during classes. All missing coding
statements were provided there with explanation. Create and Submit a Word file
Lab6ProgramminAlgorithmsandPatternsYourName.docx which includes output screenshots
for every Java Project. Submit Java projects too.

1. Stream Processing
Create StreamProcessingProject as done during class to demonstrate the use of stream
processing methods as shown hereafter in Figure.

420-930-VA Prog. Algorithms 1/4 CEGEP VANIER COLLEGE 2024


2. Applying Stream Processing to Trip HashSet collection

• Complete LambdaTripProject (from Lab 5) as shown in Figure, to store the records of the
file Trip.in (use delimiter \t to read Trip.in) onto an HashSet.
• Use created Java class Trip.
• Add every record stored as an object into HashSet.

Applying Stream Processing to Trip HashSet collection


• Invoke collection stream methods in the main class to process elements of the Trip
HashSet such as filter, sorted, max, min, anyMatch, as shown hereafter:
• Display the Number of Employees in the HashSet whose Total Trip Cost > 400$
• Display Employees in the HashSet sorted by Emp_id.
• Display Employees in the HashSet sorted by CalculateCostTrip.
• Display Max Cost Trip of Employee in the HashSet.
• Display Min Cost Trip of Employee in the HashSet.
• Display if Employee Trip info matching emp_name "Eduard" is in the HashSet.
• Display all Employee Trip info all matching emp_name "Paul" in the HashSet.

3. Applying Stream Processing to HashMap collection

• Create LambdaHashMapFacultyProject as shown in Figure, to store the records of the file


Faculty.in (use delimiter \t to read Faculty.in (from Lab 5)) onto HashMap.
• Created already Java class Faculty (the same as from Lab 5, to define data structure type,
called Faculty.
• Add every record stored as an object into HashMap.

420-930-VA Prog. Algorithms 2/4 CEGEP VANIER COLLEGE 2024


• Display the number of elements of the HashMap.
• Print all elements of the HashMap keys applying Lambda expression as shown hereafter.

• Print then all elements of faculty HashMap applying Lambda expression invoking
toString( ) method as shown hereafter.

• Print all elements of the HashMap sorted with respect to key f_Id as shown hereafter.

• Print all elements of the HashMap sorted with respect to value of faculty bonus invoking
doCalc_Bonus() as shown hereafter.

• Print all elements of the HashMap sorted with respect to value of faculty tax bonus
invoking doBonus_tax().
• Print all elements of the HashMap sorted with respect to value of faculty salary.
420-930-VA Prog. Algorithms 3/4 CEGEP VANIER COLLEGE 2024
• Print all elements of the HashMap sorted with respect to value of faculty f_Lname as
shown hereafter.

• Print all elements of the HashMap sorted with respect to value of faculty f_Lname in
reverse order as shown hereafter.

• Display Max Faculty bonus in the faculty HashMap as shown hereafter.

• Search for any matching key of Faculty last name "Smith" in HashMap using filter( ) as
shown hereafter.

• Search for any matching of Faculty bonus rate of "1.5" in HashMap using filter( ) as
shown hereafter.

420-930-VA Prog. Algorithms 4/4 CEGEP VANIER COLLEGE 2024

You might also like