Question: please write a java program by following all the requirements. there is all the information here is the related link: public class GroceryBill { private

please write a java program by following all the requirements.

there is all the information

here is the related link:

public class GroceryBill { private Employee clerk; private List receipt; private double total; private double internalDiscount; public GroceryBill(Employee clerk) { this.clerk = clerk; receipt = new ArrayList(); total = 0.0; internalDiscount = 0.0; } public void add(Item i) { receipt.add(i); total += i.getPrice(); internalDiscount += i.getDiscount(); } public double getTotal() { return Math.rint(total * 100) / 100.0; } public Employee getClerk() { return clerk; } public void printReceipt() { System.out.println(this); } private String valueToString(double value) { value = Math.rint(value * 100) / 100.0; String result = "" + Math.abs(value); if(result.indexOf(".") == result.length() - 2) { result += "0"; } result = "$" + result; return result; } public String receiptToString() { String build = "items: "; for(int i = 0; i  

please write a java program by following all the requirements. there is

Language Type: Related Links: Author: Java classes implementing inheritance instance methods GroceryBilljava Robert Baxter (on 2019/09/19) Suppose a class GroceryBill keeps track of a list of items being purchased at a market: Method/Constructor public GroceryBill(Employee clerk) public void add (Item i) public double getTotal() public void printReceipt() Description constructs a GroceryBill object for the given clerk adds i to this bill's total returns the cost of these items prints a list of items GroceryBill objects interact with Item objects. An Item has the following public methods: Method/Constructor Description public double getPrice) returns the price for this item public double getDiscount() returns the discount for this item For example, 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 items will have no discount, 0.0.) Currently the above classes do not consider discounts. Every item in a bill is charged full price, and item discounts are ignored. Define a class DiscountBill that extends GroceryBill to compute discounts for preferred customers. The constructor for DiscountBill accepts a parameter for whether the customer should get the discount. Your class should adjust the amount reported by getTotal for preferred customers. For example, if the total would have been $80 but a preferred customer is getting $20 in discounts, then getTotal should report the total as $60 for that customer. You should also keep track of how many items a customer is getting a non-zero discount for and the overall discount, both as a total amount and as a percentage of the original bill. Include the extra methods below that allow a client to ask about the discount: Method/Constructor public Discount Bill(Employee clerk, boolean preferred) public int getDiscount Count() public double getDiscount Amount() public double getDiscountPercent) Description constructs discount bill for given clerk 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 If the customer is not a preferred customer the DiscountBill behaves at all times as if there is a total discount of 0.0 and no items have been discounted

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 Databases Questions!