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

Java Library Author Diversity Program

The document outlines a Java programming task involving the creation of classes for Libraries, Sections, and Books. It requires the implementation of two static methods to filter libraries by author diversity and to summarize books by authors in each city. Sample inputs and expected outputs are provided to illustrate the functionality of the program.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Java Library Author Diversity Program

The document outlines a Java programming task involving the creation of classes for Libraries, Sections, and Books. It requires the implementation of two static methods to filter libraries by author diversity and to summarize books by authors in each city. Sample inputs and expected outputs are provided to illustrate the functionality of the program.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Object-Oriented Programming Question

Problem Statement

You are given a list of Libraries. Each Library has a unique ID, name, and city.

Each Library contains multiple Sections (like Science, Literature, etc). Each Section has a section ID,

a name, and a list of Books. Each Book has a unique book ID, title, author, and price.

Your task is to write a Java program with appropriate classes: Library, Section, Book. After input is parsed,

implement the following two static methods:

1. filterLibrariesByAuthorDiversity(List<Library> libraries, int minAuthorCount)

- Print the names of libraries that have books written by at least 'minAuthorCount' unique authors.

2. printCityAuthorBookSummary(List<Library> libraries)

- For each city, group books by author.

- For each author, list the unique book titles they have written in that city.

- Maintain input order of cities and authors.

Sample Inputs and Expected Outputs

--- Sample Input 1 ---

101

Central Library

Delhi

11

Science

201

Physics Made Easy

Dr. Kumar
Java Object-Oriented Programming Question

250.0

202

Quantum Realm

Dr. Kumar

300.0

12

Literature

203

Poetry 101

Emily Frost

150.0

204

Classic Tales

John Keats

180.0

102

City Library

Mumbai

13

Mixed Section

205

Oceanography

Dr. Kumar

270.0

206

Nature's Law

Emily Frost

290.0
Java Object-Oriented Programming Question

207

Quantum Realm

Dr. Kumar

300.0

--- Expected Output 1 ---

Central Library

City Library

Delhi

Dr. Kumar: [Physics Made Easy, Quantum Realm]

Emily Frost: [Poetry 101]

John Keats: [Classic Tales]

Mumbai

Dr. Kumar: [Oceanography, Quantum Realm]

Emily Frost: [Nature's Law]

--- Sample Input 2 ---

201

Tech Library

Bangalore

21

Engineering

301

Machine Learning

Alice Smith

500.0

302
Java Object-Oriented Programming Question

AI Basics

Alice Smith

450.0

--- Expected Output 2 ---

(No output from first method since only 1 author)

Bangalore

Alice Smith: [Machine Learning, AI Basics]

You might also like