40Filtering Records

Sorting records is helpful, but sometimes you need to filter down the results to find or display only what you’re looking for.

Given the following data set

First Name

Last Name

Position

Separation date

John

Johnson

Manager

2016-12-31

Tou

Xiong

Software Engineer

2016-10-05

Michaela

Michaelson

District Manager

2015-12-19

Jake

Jacobson

Programmer

Jacquelyn

Jackson

DBA

Sally

Weber

Web Developer

2015-12-18

create a program that lets a user locate all records that match the search string by comparing the search string to the first or last name field.

Example Output

 
Enter a search string: Jac
 
 
Results:
 
Name | Position | Separation Date
 
--------------------|-------------------|----------------
 
Jacquelyn Jackson | DBA |
 
Jake Jacobson | Programmer |

Constraint

  • Implement the data using an array of maps or an associative array.

Challenges

  • Make the search case insensitive.

  • Add the option to search by position.

  • Add the option to find all employees where their separation date is six months ago or more.

  • Read in the data from a file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.190.41