#C240. List Books by Author
List Books by Author
List Books by Author
You are given a list of books and an author's name. Each book has a title and an author. Your task is to list all books written by the specified author in a case-insensitive manner. The output should be printed in tabular format with two columns: one for the title (left-justified in a width of 30 characters) and one for the author. After listing the books, print the total number of matching books in the following format:
Number of books by [author_name]: [count]
Note: The input will be given via stdin and the output should be written to stdout. If no books match, only the header and the count (which will be 0) should be printed.
For example, if the input is as follows:
4 Eloquent JavaScript;Marijn Haverbeke JavaScript: The Good Parts;Douglas Crockford You Don't Know JS;Kyle Simpson Eloquent JavaScript;marijn haverbeke marijn haverbeke
The output should be:
Title Author Eloquent JavaScript Marijn Haverbeke Eloquent JavaScript marijn haverbeke Number of books by marijn haverbeke: 2
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer N, which indicates the number of books.
- The next N lines each contain a book's information in the format: ; (the title and the author are separated by a semicolon).
- The final line contains the author name to search for.
outputFormat
The output is printed to standard output (stdout) and must include:
- A header line: 'Title Author' (with 'Title' left-justified in a field of width 30).
- For each book that matches the given author name (case-insensitive), a line containing the title (left-justified in a field of width 30) followed by the author.
- A final line that prints the total count in the format: 'Number of books by [author_name]: [count]'.
Make sure the formatting (spaces and newlines) is exactly as specified.## sample
4
Eloquent JavaScript;Marijn Haverbeke
JavaScript: The Good Parts;Douglas Crockford
You Don't Know JS;Kyle Simpson
Eloquent JavaScript;marijn haverbeke
marijn haverbeke
Title Author
Eloquent JavaScript Marijn Haverbeke
Eloquent JavaScript marijn haverbeke
Number of books by marijn haverbeke: 2
</p>