Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 10, Chapter9 in Building Java Programs textbook. Please help! If possible, please leave some comment lines itll help me a lot! Thank you! Bill.

Question 10, Chapter9 in Building Java Programs textbook.
Please help! If possible, please leave some comment lines itll help me a lot!
Thank you! image text in transcribed
image text in transcribed
Bill. Suppose a class GroceryBill keeps track of a list of items being purchased at a market: public Grocery111(Employee clerk) public void add (Item i) public double getTotal() public void printReceipt() Constructs a grocery bill object for the given clerk Adds the given item to this bill Returns the total cost of these items Prints a list of items Grocery bills interact with Item objects, each of which has the public methods that follow. A candy bar item might cost 1.35 with a discount of 0.25 for preferred customers, meaning that preferred customers get it for 1.10. (Some unts. Every item in abia items will have no discount, 0.0.) Currently the preceding classes do not consider discounts. Every charged full price, and item discounts are ignored. public double getPrice () public double getDiscount() Returns the price for this item Returns the discount for this item Define a class Discount B111 that extends GroceryBill to compute discounts for preferred customer structor accepts a parameter for whether the customer should get the discount. Your class should also adius reported for preferred customers. For example, if the total would have been $80 but a preferred customer is $20 in discounts, then getTotal should report the total as $60 for that customer. Also keep track of the number of items on which a customer is getting a nonzero discount and the sum of these discounts, both as a totala and as a percentage of the original bill. Include the extra methods that follow, which allow a client to ask about the discount. Return 0.0 if the customer is not a preferred customer or if no items were discounted. Constructs bill for given clerk public DiscountBill (Employee clerk, boolean preferred) public int getDiscount Count() public double getDiscount Amount() public double getDiscount Percent() Returns the number of items that were discounted, if any, Returns the total discount for this list of items, if any Returns the percent of the total discount as a percent of what the total would have been otherwise

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions