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. 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. 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. 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 nontaxable the tax is Assume that soap and soda are
taxable, but chips and cereal are not. 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
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. point
A public setter for the retail item lookup. point
A public method startTransaction that creates a new instance of the
purchased items ArrayList. point
A public method scanItem that takes a retail item and adds it to the
purchased items ArrayList. 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. 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. points
A public method to print a formatted receipt. It should print each purchased
item and its price remember the implicit toStringmethod for enums
the subtotal, the tax and the total. 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. point
Instantiate a RetailItemLookup object initialized with the tax rate value
and the item price array. points
Use the static setter to set the retailItemLookup field of the
CashRegister class. points
Instantiate a CashRegister object and test it with three separate
transactions: all groceries, all nongroceries, and some of each. points
Your output should look similar to this:
CHIPS $
CEREAL $
Subtotal $
Tax $
Total $
SOAP $
SODA $
Subtotal $
Tax $
Total $
CHIPS $
CEREAL $
SOAP $
SODA $
Subtotal $
Tax $
Total $
Notes:
Your classes and methods should have javadocs. Uncommented code is an
automatic point deduction.
Please help asap!!!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
