(Exercises #6, Page 358) Consider a class that keeps track of the sales of an item. An object of this class will have the attributes:
And the following methods:
registerSale(n)
Records the sale of n
items. If n
is equal to or larger
than the bulk quatity, the cost per item will be reduced by the bulk discount.
displaySales()
Displays the number sold, the total sales, and total discount.
Implement the class in Java and write some Java code to test the class.
Name these programs ItemSales & ItemSalesDemo
(Exercises #7, Page 359) Consider the class MotorBoat
that represents motorboarts. A motorboat
has attributes for:
The class has the following methods:
If the boat has efficiency e
, the amount of fuel used when traveling at a speed
s
for time t
is (e * (s^2) * t)
. The distance traveled
in that time is (s * t)
.
Implement the class in Java and write some Java code to test the class.
Name these programs MotorBoat & MotorBoatDemo