Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#Java java.lang. Comparable ScienceBook quantity: int + compareTo o :Object): int + ScienceBook (title: String, price: double, quantity: int) + calculateTotalPrice (): double + toString():

image text in transcribed

image text in transcribed

#Java

java.lang. Comparable ScienceBook quantity: int + compareTo o :Object): int + ScienceBook (title: String, price: double, quantity: int) + calculateTotalPrice (): double + toString(): String Book # title: String # price: double + Book() + Book(title: String, price: double) Write a complete Java program for the scienceBook, Book and test classes based on Figure 1 above and the following requirements: The class ScienceBook is derived from Book and implements interface java.lang.Comparable. There are two methods in ScienceBook class which are: Method calculateTotalPrice () that is used to calculate the total price by multiplying quantity and price Method toString (will return all information of scienceBook Class ScienceBook implements compareTo () method from java.lang.Comparable to compare the total price obtained by two its objects. If the total price of first object larger than second object then it will return 1, if first object smaller than second object then it will retum -1 and 0 will be returned if total price for both objects are equal. In a test class, create two ScienceBook objects. Prompt a user to enter the values for title, quantity and price for each object. Then display information for the both objects including the comparison of object total price

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

ISBN: 0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

Identify and describe the security problems cloud computing poses.

Answered: 1 week ago