0% found this document useful (0 votes)
2 views2 pages

Files

Uploaded by

swarajya laxmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Files

Uploaded by

swarajya laxmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1. You are a librarian at a university library.

You need to manage a collection of


books, including their titles, authors, publication years, and genres. You want to
store this information in a file named "books.txt" and perform various operations
like adding, removing, searching, and sorting books.

Task:

Write a Java program that uses the following:

- Files: to read and write book information to "books.txt"


- Comparator: to sort books by title, author, publication year, and genre
- Arrays: to store book information temporarily
- HashMap: to store book information with title as the key
- TreeSet: to store book information in a sorted order
- Scanner: to get user input

Operations:

- Add book: prompt the user for book information and add it to the HashMap and
TreeSet
- Remove book: prompt the user for a book title and remove it from the HashMap and
TreeSet
- Search book: prompt the user for a book title and display its information if
found
- Sort books: sort the books in the TreeSet by title, author, publication year, and
genre
- Display books: display all books in the TreeSet

Java Question:

Write a Java program that implements the above scenario and operations. Use the
following classes:

- Book: to represent a book with title, author, publication year, and genre
- Library: to manage the book collection using HashMap and TreeSet

Note: Use appropriate methods and variables to implement the operations. Use the
Scanner class to get user input.

-----------------------------------------------------------------------------------
--------------------------------

2. Problem Statement:

You are the HR manager of a company. You need to manage the employees' data. Each
employee has a name, ID, department, job title, and a salary. You need to store the
employees in a data structure and perform the following operations:

- Add an employee to the company


- Remove an employee from the company
- Search for an employee by name or ID
- Display all employees in the company sorted by their salaries
- Display all employees in the company sorted by their job titles
- Display the top 5 highest-paid employees in the company

Requirements:

- Use an enumeration for the departments (e.g. Sales, Marketing, IT, etc.)
- Use a Comparator to sort the employees by their salaries and job titles
- Use auto-boxing to convert the salaries to Double objects
- Use a Scanner to read input from the user
- Use a Map to store the employees, where the key is the employee ID and the value
is the employee object
- Use a List to store the employees in the order they were added
- Use a Set to store the unique job titles
- Use a PriorityQueue to store the top 5 highest-paid employees
- Use a Deque to store the employees in a queue for processing
- Use an Iterator to access the employees in the collection
- Use the sorting operations to sort the employees by their salaries and job titles

You might also like