Question: tax values for retail items. This class should have: Two immutable fields for tax rate and an array of prices for enumerated retail items. (

tax values for retail items. This class should have:
Two immutable fields for tax rate and an array of prices for enumerated retail
items. (1 point)
A constructor that takes the tax rate and the price array and initializes the above
fields with their values. Remember to copy array elements from the parameter
array so you dont create a security vulnerability. (2 points)
A public method that takes a retail item and returns its price. To find the correct
price use the ordinal value of the retail item. (1 point)
A public method that takes a retail item and uses a switch statement to
compute the tax. For taxable items the value is the price for the item times the
tax rate, and for non-taxable the tax is 0. Assume that soap and soda are
taxable, but chips and cereal are not. (2 points)
A class CashRegister to simulate the cash register. This class should have:
A field for the retail item lookup reference. All instances of the
CashRegister class should use the same instance of RetailItemLookup
(1 point)
An ArrayList to hold all purchased items for each customer transaction.
Each instance of the CashRegister should have its own instance of the
purchased items ArrayList. (1 point)
A public setter for the retail item lookup. (1 point)
A public method startTransaction that creates a new instance of the
purchased items ArrayList. (1 point)
A public method scanItem that takes a retail item and adds it to the
purchased items ArrayList. (1 point)
A private method to calculate the subtotal for the transaction. It should use the
enhanced for loop to iterate over the purchased items ArrayList, look up
the item price and add it to the rolling subtotal for each iteration. (2 points)
A private method to calculate the tax. It should also use the enhanced for loop
to iterate over the purchased items, look up the tax value for the item, and add
it to the rolling total tax. (2 points)
A public method to print a formatted receipt. It should print each purchased
item and its price (remember the implicit toString()method for enums),
the subtotal, the tax and the total. (3 points)
A CashRegisterDemo class with the main() method. The main() method
should:
Create an array of double for the item prices. Each prices index should be the
ordinal value of the corresponding retail item. (1 point)
Instantiate a RetailItemLookup object initialized with the tax rate value
and the item price array. (.5 points)
Use the static setter to set the retailItemLookup field of the
CashRegister class. (.5 points)
Instantiate a CashRegister object and test it with three separate
transactions: all groceries, all non-groceries, and some of each. (3 points)
Your output should look similar to this:
CHIPS $ 2.49
CEREAL $ 3.25
Subtotal $ 5.74
Tax $ 0.00
Total $ 5.74
----------------
SOAP $ 1.79
SODA $ 2.99
Subtotal $ 4.78
Tax $ 0.39
Total $ 5.17
----------------
CHIPS $ 2.49
CEREAL $ 3.25
SOAP $ 1.79
SODA $ 2.99
Subtotal $10.52
Tax $ 0.39
Total $10.91
----------------
Notes:
Your classes and methods should have javadocs. Uncommented code is an
automatic 1-point deduction.
Please help asap!!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!