To test your code below and use values from the link provided.

📌 Note: There’s no need to add import java.util.ArrayList; in any of the tasks below. The ArrayList has already been imported at the backend for you. You can use it directly.

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 in a 2D array. Write the piece of code to answer the questions below.

Write the authorBooks method with the following signature:

public static int authorBooks(String author, String[][] dataset)

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

Remember: a book may be rated among the top 50 multiple times. Make sure to only include a book once. The idea is to use an ArrayList and the contains() method on it and return the size at the end.

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

Get hands-on with 1200+ tech skills courses.