Question: 8. Define a class named Item that includes: - attributes representing an item's description and unit price (note: the unit price is the cost of
8. Define a class named Item that includes: - attributes representing an item's description and unit price (note: the unit price is the cost of one item and may have a fractional part, e.g. 4.50) a constructor that is passed 2 parameters and initializes the corresponding instance variables - a method named computeTotalCost that receives one parameter representing the number of items purchased, and computes and returns the total cost of the items purchased, including sales tax which is 8.25% - a method named equals that returns true if this item has the same description and unit price as that of the Item object received as the parameter; false otherwise - a metho representation of this Item that includes the values of all attributes. d named toString that receives no parameters and returns a formatted String driver code (a static test method of the same class, or a main method in another class) that instantiates (creates) 2 objects of type Item and invokes the above methods appropriately. For each method that you call (i.e. the computeTotalCost and equals methods), print the actual result returned by the method and the expected result Print only in your driver code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
