Home / Expert Answers / Computer Science / python-write-a-class-named-cashregister-that-tracks-the-item-count-and-the-total-amount-due-the-co-pa406

(Solved): PYTHON: Write a class named CashRegister that tracks the item count and the total amount due. The co ...



PYTHON: Write a class named CashRegister that tracks the item count and the total amount due. The constructor section of this class should have the instance variables that include itemCount and totalPrice, taxableTotal, taxRate. The constructor section also allows the user to input one additional parameter called taxRate which provides the tax rate.

Implement four methods in this class include clear() to clear all transactions, getCount() to get total items, getTotal() to get total price and addItems(). For addItem() it allows the user to have two inputs provided when calling for these (price, taxable). taxable allows the user to have two values only (True as taxable or False as non-taxable). Under addItem(), you need to have the mechanism to determine if an item is taxable. If yes, you need to update taxableTotal by adding the price.

For getTotal(), it will return the totalPrice plus taxableTotal if one item is taxable. If no, only totalPrice. taxableTotal is equal to self._taxableTotal * self._taxRate / 100.

Then, write a test file to generate two objects.

First object has the tax rate 7.5. This object adds two items (one with price 10, non taxable; one with price 19.55 taxable).

Second object has the tax rate 11.2. This object adds three items (one with price 20 and non-taxable; one with price 11.2 and taxable; one with price 3 and taxable).

You need to turn in two .py files; one for CashRegister() and one for the test file.

Sample example:

First object
Total items for first object: 2
Total price for first object: \( 31.02 \)
Second object
Total items for second o

 

 

First object Total items for first object: 2 Total price for first object: \( 31.02 \) Second object Total items for second object: 3 Total price for second object: \( 35.79 \)


We have an Answer from Expert

View Expert Answer

Expert Answer


# # # # # # # # # CashRegister.py file which holds CashRegister class class CashRegister: def __init__(self, taxR

We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe