Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are building a library management system. An object of the Book class represents each book in the library. Declare an array of Book objects

You are building a library management system. An object of the Book class represents
each book in the library. Declare an array of Book objects to store information about
five different books.
3.1 The following is a Book class and an incomplete program that declares an array
of Book objects to store information about five different books. Provide the missing
code that displays the book list. (4 marks)
1. public class Book {
2. private String title;
3. private String author;
4 HSYD100-1-Jan-Jun2024-FA2-OD-V.2-08112023
4. public String getTitle(){
5. return title;
6.}
7. public void setTitle(String title){
8. this.title = title;
9.}
10. public String getAuthor(){
11. return author;
12.}
13. public void setAuthor(String author){
14. this.author = author;
15.}
16. public Book(String title, String author){
17. this.title = title;
18. this.author = author;
19.}
20.}
1. public class LibrarySystem {
2. public static void main(String[] args){
3. Book[] books = new Book[5];
4. books[0]= new Book("Java Programming", "John Smith");
5. books[1]= new Book("Data Structures", "Alice Johnson");
6. books[2]= new Book("Machine Learning", "David Williams");
7. books[3]= new Book("Algorithms", "Emily Davis");
8. books[4]= new Book("Web Development", "Michael Brown");
9. MISSING statement? (2 marks)
10. MISSING statement? (2 marks)
11. MISSING statement?
12.}//end main method
5 HSYD100-1-Jan-Jun2024-FA2-OD-V.2-08112023
13.}//end class LibrarySystem

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

In which ways would you measure training success? Explain.

Answered: 1 week ago