Home / Expert Answers / Computer Science / nbsp-nbsp-given-main-and-a-base-book-class-define-a-derived-class-called-encyclopedia-pa142

(Solved):     Given main() and a base Book class, define a derived class called Encyclopedia. ...



Given main() and a base Book class, define a derived class called Encyclopedia. Within the derived Encyclopedia class, define

import java.util.Scanner;
oublic class BookInformation \( \{ \).
public static void main(String[] args) \{
Scanner \( \operat\}Current file: Encyclopedia.java \( \vee \)
Load default template...
1 public class Encyclopedia extends Book \{
// TODO: Decl

 

 

Given main() and a base Book class, define a derived class called Encyclopedia. Within the derived Encyclopedia class, define a printinfo() method that overrides the Book class' printInfo0 method by printing not only the title, author, publisher, and publication date, but also the edition and number of volumes. Ex. If the input is: The Hobbit J. R. R. Tolkien George Allen \& Unwin 21 september 1937 The Illustrated Encyclopedia of the James \( W \). Guthrie Watson-Guptill 2001 2nd 1 The Illustrated Encyclopedia of the Universe the output is: Book Information: Book Title: The Hobbit Author: J. R. R. Tolkien Publisher: George Allen \& Unwin Publication Date: 21 September 1937 Book Information: Book Title: The Illustrated Encyclopedia of the Universe Author: James W. Guthrie Publisher: Watson-Guptill Publication Date: 2001 Edition: 2nd Number of Volumes: 1 import java.util.Scanner; oublic class BookInformation \( \{ \). public static void main(String[] args) \{ Scanner \( \operatorname{scn} r= \) new Scanner(System.in); Book myBook \( = \) new \( \operatorname{Book}() \); Encyclopedia myEncyclopedia = new Encyclopedia(); String title, author, publisher, publicationDate; String eTitle, eAuthor, ePublisher, ePublicationDate, edition; int numVolumes; title = scnr. nextLine(); author = scnr. nextLine(); publisher = scnr. nextLine(); publicationDate \( = \) scnr. nextLine(); eTitle = scnr. nextLine(); eAuthor = scnr. nextline(); ePublisher = scnr. nextLine(); ePublicationDate = senr. nextLine(); edition = scnr. nextline(); numVolumes \( = \) scnr. nextInt(); myBook. setTitle(title); myBook. setAuthor (author); myBook. setPublisher (publisher); myBook. setPublicationDate(publicationDate); myBook. printinfo(); myEncyclopedia. setTitle(eTitle); myEncyclopedia. setAuthor (eAuthor); myEncyclopedia. setPublisher (ePublisher); myEncyclopedia. setPublicationDate(ePublicationDate); myEncyclopedia.setedition(edition); myEncyclopedia. setNumVolumes (numVolumes); myEncyclopedia. printInfo(); \} \} Current file: Encyclopedia.java \( \vee \) Load default template... 1 public class Encyclopedia extends Book \{ // TODO: Declare private fields: edition, numvolumes 1/ TODO: Define mutator methods - II setEdition(), setNumvolumes() 1/ TODO: Define accessor methods - II getEdition(), getNumVolumes() 1/ TODO: Define a printInfo() method that overrides 1/ the printinfo in Book class


We have an Answer from Expert

View Expert Answer

Expert Answer


Answer: Note: To Create a Java program. Open a java IDE. Make a file name of your choice with the extension ".java" Make sure that your file name and
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe