Search⌘ K
AI Features

Time To Code

Explore hands-on Java coding tasks using the Amazon Top 50 Bestselling Books dataset. Learn to count books by authors, list all authors, retrieve unique book titles, filter by user ratings, and find book prices. Gain practical experience in manipulating object-oriented data structures and enhancing your data processing skills.

Task I: Total number of books by an author

Our task is to find the total number of books written by specific authors.

✏️ Note: Below is the same code we saw in the previous lesson to read the dataset as objects of book class. Write the piece of code to answer the questions below.

It takes the name of an author and dataset as input and returns the total number of books written by the author.

Input: J.K. Rowling

Expected output:

Total number of books by J.K. Rowling: 6

Just for reference, Author is the second column in the dataset.

Java
import java.util.List;
class Driver {
public static void main(String[] args) {
// Replace the following line of code and implement your solution here
System.out.println("Total number of books by author X: Y");
}
}

If you’re unsure how to do this, click the “Show Hint” button.

Task II: All the authors in the dataset

Our task is to find the names of all the authors present in the dataset.

Remember: many records may have the same author, so don’t consider the same author multiple times.

Expected output: List name of all authors in the dataset.

Just for reference, Author is the second column in the ...