import java.util.Scanner; public class Book { private String title; private int pyear; private String author; public Book() { this("",0,""); } public Book(String tlt,int py,String ath) { title=tlt; pyear=py; author=ath; } public void setTitle(String tlt) { title=tlt; } public void setPYear(int py) { pyear=py; } public void setAuthor(String ath) { author=ath; } public String getTitle() { return title; } public int getPyear() { return pyear; } public String getAuthor() { return author; } public void print() { System.out.println("Title of the book is "+title); System.out.println("Publication year is "+pyear); System.out.println("The Author is "+author); } public static void main(String[] args) { Book[] ba=new Book[5]; String t,a; int p; Scanner input=new Scanner(System.in); for(int i=0;i<5;i++){ System.out.println("Enter the Title of the book"); t=input.nextLine(); System.out.println("Enter the publicatuion year of the book"); p=input.nextInt(); input.nextLine(); System.out.println("Enter the author of the book"); a=input.nextLine(); // Book b=new Book(t,p,a); // ba[i]=b; ba[i]=new Book(t,p,a); } for(int i=0;i<5;i++) { ba[i].print(); System.out.println("******************"); } } }