The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Write a CashRegister class that can be used with the RetailItemclass that you wrote in Chapter 6's Programming Challenge 4. TheCashRegister class should simulate the sale of a retail item. Itshould have a constructor that accepts a RetailItem object as anargument. The constructor should also accept an integer thatrepresents the quantity of items being purchased. In addition, theclass should have the following methods:
• The getSubtotal method should return the subtotal of the sale,which is the quantity multiplied by the price. This method must getthe price from the RetailItem object that was passed as an argumentto the constructor.
• The getTax method should return the amount of sales tax on thepurchase. The sales tax rate is 6 percent of a retail sale.
• The getTotal method should return the total of the sale, which isthe subtotal plus the sales tax.
Â
Demonstrate the class in a program that asks the user for thequantity of items being purchased and then displays the sale’ssubtotal, amount of sales tax and total.
-----------