Java Question - Using the bottom code, create another class named "DigitalBook" as a subclass of the given "Book" class. Then, Make sure that the "DigitalBook" class contains two constructors: (1) one is the default constructor that takes no parameter, and (2) the other is a parameterized constructor that take 6 parameters. Be sure to use the “super” keyword in the constructors of the "DigitalBook" class. In the “main()” method of the “EX12_1” class, create four instances: “b1”, “b2”, d1”, and “d2”. Let “b1” and “b2” be the instances of the “Book” class, and let the “d1” and “d2” be the instance of the “DigitalBook” class. Be sure to use the specified constructor (as shown in attached picture) to initialize these instances. The Final Output is shown in the attached pictures. Please make sure that no errors show up in the Java Compiler when testing the code. Thank you.  Add the following code to the "class Book" code (Below the ___ line). public class EX12_1 { public static void main(String[] args) { /////add your code here } } ________________________________________________________________________________ class Book { public int totalPage, totalChapter; public double unitPrice; public String title, author, ISBN; public String format = "Paper"; public Book() { } public Book(String tl, String at, String isbn, int tp, int tc, double up) { title = tl; author = at; ISBN = isbn; totalPage = tp; totalChapter = tc; unitPrice = up; } void showBook() { System.out.println("Title: " + title); System.out.println("Author: " + author); System.out.println("ISBN: " + ISBN); System.out.println("Total Pages: " + totalPage); System.out.println("Total Chapters: " + totalChapter); System.out.println("Unit Price: " + unitPrice); System.out.println("Format: " + format + "\n"); } }

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter10: Classes And Objects
Section: Chapter Questions
Problem 5RQ: Which of the following statements is false? a. A class can contain only one constructor. b. An...
icon
Related questions
Question

Java Question - Using the bottom code, create another class named "DigitalBook" as a subclass of the given "Book" class. Then, Make sure that the "DigitalBook" class contains two constructors:

(1) one is the default constructor that takes no parameter, and (2) the other is a parameterized constructor that take 6 parameters. Be sure to use the “super” keyword in the constructors of the "DigitalBook" class. In the “main()” method of the “EX12_1” class, create four instances: “b1”, “b2”, d1”, and “d2”. Let “b1” and “b2” be the instances of the “Book” class, and let the “d1” and “d2” be the instance of the “DigitalBook” class. Be sure to use the specified constructor (as shown in attached picture) to initialize these instances. The Final Output is shown in the attached pictures. Please make sure that no errors show up in the Java Compiler when testing the code. Thank you. 

Add the following code to the "class Book" code (Below the ___ line).

public class EX12_1
{
public static void main(String[] args)
{
/////add your code here
}
}

________________________________________________________________________________

class Book
{
public int totalPage, totalChapter;
public double unitPrice;
public String title, author, ISBN;
public String format = "Paper";
public Book() { }
public Book(String tl, String at, String isbn, int tp, int tc, double up)
{
title = tl;
author = at;
ISBN = isbn;
totalPage = tp;
totalChapter = tc;
unitPrice = up;
}
void showBook()
{
System.out.println("Title: " + title);
System.out.println("Author: " + author);
System.out.println("ISBN: " + ISBN);
System.out.println("Total Pages: " + totalPage);
System.out.println("Total Chapters: " + totalChapter);
System.out.println("Unit Price: " + unitPrice);
System.out.println("Format: " + format + "\n");
}

}

 

7. Finally, use the “showBook()" method to display the details of the four books. Make sure the output looks
similar to the following.
Title: Jane Eyre
Author: Charlotte Bronte
ISBN: 9-871357-641
Total Pages: 150
Total Chapters: 10
Unit Price: 12.75
Format: Paper
Title: Alice in Wonderland
Author: Lewis Carroll
ISBN: 9-871245-237
Total Pages: 124
Total Chapters: 14
Unit Price: 24.95
Format: Paper
Title: Little Women
Author: Louisa Alcott
ISBN: 9-2436124-775
Total Pages: 120
Total Chapters: 9
Unit Price: 10.75
Format: PDF
Title: CIS226
Author: Cypress College
ISBN: 9-842654-291
Total Pages: 581
Total Chapters: 14
Unit Price: 5.15
Format: PDF
Transcribed Image Text:7. Finally, use the “showBook()" method to display the details of the four books. Make sure the output looks similar to the following. Title: Jane Eyre Author: Charlotte Bronte ISBN: 9-871357-641 Total Pages: 150 Total Chapters: 10 Unit Price: 12.75 Format: Paper Title: Alice in Wonderland Author: Lewis Carroll ISBN: 9-871245-237 Total Pages: 124 Total Chapters: 14 Unit Price: 24.95 Format: Paper Title: Little Women Author: Louisa Alcott ISBN: 9-2436124-775 Total Pages: 120 Total Chapters: 9 Unit Price: 10.75 Format: PDF Title: CIS226 Author: Cypress College ISBN: 9-842654-291 Total Pages: 581 Total Chapters: 14 Unit Price: 5.15 Format: PDF
Instance
constructor
Values
b1
Default constructor of "Book" class
Title: "Alice in Wonderland"
Author: "Lewis Carroll"
ISBN: "9-871245-237"
Total Page: 124
Total Chapter: 14
Unit Price: 24.95
Title: "Jane Eyre"
Author: "Charlotte Bronte"
b2
Parameterized constructor of the "Book" class
ISBN: "9-871357-641"
Total Page: 150
Total Chapter: 10
Unit Price: 12.75
dl
Default constructor of "DigitalBook" class
Title: "Little Women"
Author: "Louisa Alcott"
ISBN: "9-2436124-775"
Total Page: 120
Total Chapter: 9
Unit Price: 10.75
• Title: "CIS226"
• Author: "Cypress College"
ISBN: "9-842654-291"
Total Page: 581
Total Chapter: 15
Parameterized constructor of the “DigitalBook" class
d2
Unit Price: 5.15
Transcribed Image Text:Instance constructor Values b1 Default constructor of "Book" class Title: "Alice in Wonderland" Author: "Lewis Carroll" ISBN: "9-871245-237" Total Page: 124 Total Chapter: 14 Unit Price: 24.95 Title: "Jane Eyre" Author: "Charlotte Bronte" b2 Parameterized constructor of the "Book" class ISBN: "9-871357-641" Total Page: 150 Total Chapter: 10 Unit Price: 12.75 dl Default constructor of "DigitalBook" class Title: "Little Women" Author: "Louisa Alcott" ISBN: "9-2436124-775" Total Page: 120 Total Chapter: 9 Unit Price: 10.75 • Title: "CIS226" • Author: "Cypress College" ISBN: "9-842654-291" Total Page: 581 Total Chapter: 15 Parameterized constructor of the “DigitalBook" class d2 Unit Price: 5.15
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,