Question: Imagine you are developing a software system for a library to track the books. Each book has attributes such as title, author, and year

Imagine you are developing a software system for a library to track

 

Imagine you are developing a software system for a library to track the books. Each book has attributes such as title, author, and year of publication. Task: Create a Java program that does the following: 1. Define a Book Class: Define a class named Book. It should have three private instance variables: title (String), author (String), and year (int). Include a constructor that allows you to set all three values at once. Also, include getter methods for each of these variables. 2. Display the Information about a book: Write a method (in class Book) that prints out the information of a book in the format: "Title by Author (Year)". The method should use the defined getter methods to access the private variables. 3. Create an Array of Book Objects: In your Main class, create an array named library that can hold 5 Book objects. 4. Populate the Array: Fill the library array with five (5) different Book objects, representing books of your choice. Initialize each Book with appropriate values for title, author, and year. 5. Display the Information about all books in the library: Write a method (in class Main) that takes the array of Book objects as a parameter and prints out the information of each book in the format: "Title by Author (Year)". Use the method to display all books information.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Certainly Heres a Java program that follows the task instructions First define the Book class as spe... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!