Java - Constructors Create a class named Book that has the following attributes: Publisher - String Year Published - Integer Price - Double Title - String Create a constructor for the class Book that has the parameters from the attributes of the class. After, create a method for the class that displays all attributes. Ask the user for inputs for the attributes and use the constructor to create the object. Lastly, print the values of the attributes.   Inputs 1. Publisher   2. Year Published   3. Price   4. Book Title XYZ Publishing 2020 1000.00 How to Win?   Sample Output Published: ABC Publishing Year Published: 2022 Price: 150.00 Book Title: Stooping too low   Stooping too low is published by ABC Publishing on 2022. It sells at the price of Php150.00

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Java - Constructors

Create a class named Book that has the following attributes:

Publisher - String Year Published - Integer Price - Double Title - String

Create a constructor for the class Book that has the parameters from the attributes of the class. After, create a method for the class that displays all attributes. Ask the user for inputs for the attributes and use the constructor to create the object. Lastly, print the values of the attributes.

 

Inputs

1. Publisher

 

2. Year Published

 

3. Price

 

4. Book Title

XYZ Publishing 2020 1000.00 How to Win?

 

Sample Output

Published: ABC Publishing
Year Published: 2022
Price: 150.00
Book Title: Stooping too low
 
Stooping too low is published by ABC Publishing on 2022. It sells at the price of Php150.00.
Test Cases
Constraints
O Constraint 1
The code must have a class called Book.
Test Cases
O Test Case 1
Your Output
No Output
Expected Output
Published: ABC Publishing
Year Published: 2022
Price: 150.00
Book Title: Stooping too low
Stooping too low is published by ABC Publishing on 2022. It sells at the price of Php150.00.
O Test Case 2 Hidden
Show Differences
Transcribed Image Text:Test Cases Constraints O Constraint 1 The code must have a class called Book. Test Cases O Test Case 1 Your Output No Output Expected Output Published: ABC Publishing Year Published: 2022 Price: 150.00 Book Title: Stooping too low Stooping too low is published by ABC Publishing on 2022. It sells at the price of Php150.00. O Test Case 2 Hidden Show Differences
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning