Question: Hi there! Can you help me with this java program. Part A: Have a class to represent a Book . This should include the following:

Hi there!

Can you help me with this java program.

Part A:

Have a class to represent aBook. This should include the following:

  1. Attributes for the Book'stitle(String),numOfPages(int),pubYear(int),genre(String),author(String) and auniquebookID(int).
  2. A default constructor which should set default values for all attributes and sets the unique value for thebookID.
  3. A general constructor which takes in values for all the class attributes except the uniquebookIDand sets them accordingly.
  4. Provide getter methods for thetitle,authorandbookIDof aBook.
  5. Provide a setter method for thegenreof aBook.
  6. Provide aprintBookDetailsmethod that prints all the details of aBook.Note:Please check expected output below.

Part B:

Have a main method in a new class calledBookDataBaseand in this method:

  1. Declare an array of 5 Book objects.
  2. Instantiate eachBookobject by obtaining the necessary attribute values from user input.
  3. Use the appropriate getter methods to print thetitle,authorandbookIDof the thirdBookin the array.
  4. TheBookin the second position must be reclassified as a "Fantasy" book. Implement this change in code.
  5. Call theprintBookDetailsmethod to print the attributes for eachBookobject.

Input

Shown below is the input order for oneBookobject.

Important Note:When using User Input to take in an integer for this question, please useInteger.parseInt(sc.nextLine())Please see example usage below.

 Scanner sc = new Scanner(System.in); int num = Integer.parseInt(sc.nextLine()); 

Input for 1 Book

 title (String) numOfPages (int) pubYear (int) genre (String) author (String) 

Sample Input for 1 Book

 Fly Fishing 128 1938 Sport J. R. Hartley 

Sample Output- output should be exactly as below:

 The third book is And Then There Were None It was written by Agatha Christie and has an ID of 3 Book Details Title: The Little Prince Pages: 120 Publish Year: 1943 Genre: fantasy Author: Antoine de Saint-Exupery ID: 1 Book Details Title: The Lord of the Rings Pages: 900 Publish Year: 1954 Genre: Fantasy Author: J. R. R. Tolkien ID: 2 Book Details Title: And Then There Were None Pages: 153 Publish Year: 1939 Genre: mystery Author: Agatha Christie ID: 3 Book Details Title: Dream of the Red Chamber Pages: 253 Publish Year: 1791 Genre: family Author: Cao Xueqin ID: 4 Book Details Title: The Master and Margarita Pages: 178 Publish Year: 1967 Genre: supernatural Author: Mikhail Bulgakov ID: 5 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!