Question: Design a class named Book that contains: A private string data field for book name (default java) A private int data field for quantity (default
Design a class named Book that contains:
A private string data field for book name (default java) A private int data field for quantity (default 10) A private double data field for price (default 50.5) A no-arg constructor that creates a default Book object A argument constructor that creates a book object with the user specified book name, quantity and price The accessor/get methods for name, quantity, and price A method named getPrice() that calculate total price of book(quantity*price) and returns the price
Write another test class that creates a Book object and also ask user to enter book name, quantity and price. Call the method and print the the answer of book information as well as total book price.
Sample run: From default constructore: Book name=java Book quantity=10 Book price=50.5 Total book price=505.0
From argument constructore: Enter book name=object Enter quantity=20 Enter price=60.5
Book name=objec Book quantity=20 Book price=60.5 Total book price=1210.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
