1. Engineering
  2. Computer Science
  3. 8 define a class named item that includes attributes...

Question: 8 define a class named item that includes attributes...

Question details

8. Define a class named Item that includes: - attributes representing an items 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 method named toString that receives no parameters and returns a formatted String representation of this Item that includes the values of all attributes - driver code (a static test method of the that instantiates (creates) 2 objects of type Item and inv 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! same class, or a main method in another class) okes the above methods
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution