Question: Directions: For this assignment, you will need to create a class called Inventoryltem that represents an inventory item in a store. Inventoryltem should have the
Directions: For this assignment, you will need to create a class called Inventoryltem that represents an inventory item in a store. Inventoryltem should have the following characteristics: Inventoryltem Variables: o A String called name using the protected visibility modifier o A double called price using the protected visibility modifier o A private static double called taxRate (initialized to 0) . Constructor o Sets the values for the instance variables name and price: public InventoryItem(String nameIn, double priceIn) Methods: o pub1ic String getName - Returns the customer name o public double calculateCostO ( - Returns the price including tax: price *(1+ taxRate) - Sets the tax rate . Return a String representation with name and price with tax o public static void setTaxRate (double taxRateIn) f o public String toString) f Example: "Computer: $789.02" return name+ ":S" + InventoryItem.setTaxRate (0.08)i inventory! tem item1 = new Inventoryltem ("Birdseed", item1 Birdseed: $8.6292 7.99); InventoryItem item2 new InventoryItem ("Picture", 10.99): item2 Picture: $11.869200000000001 Be sure to unfold these objects on the workbench to verify the field values
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
