Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please create just Java code for the methods below, no test code needed. Just the method with code Update: added information for GroceryClass. Create a

Please create just Java code for the methods below, no test code needed. Just the method with code

image text in transcribed

image text in transcribed

Update: added information for GroceryClass.

image text in transcribed

Create a class called Grocery Utilities in the com utilities package. You will be writing four methods total! If you want to add private methods to simplify your code, you can do so. Code for testing the first two methods can be found in the Demo class (shown above). You will need to write methods to test the two remaining methods in the Demo class. The first two methods in the GroceryUtilites class are shown in this outline and are explained on the next page: # com.utils GroceryUtilities adjustUPCItemCost(Groceryltem, int): double getAltemsForLoyaltyDeal(Groceryltem[], LoyaltyDeal): Groceryltem[] METHOD ONE Method adjustUPCItemCost will take one Groceryltem object and double. The double represents the percentage out of 100. Method will update the price of the grocery item by decreasing it by percentage and the method will return the updated price. For example: double price = GroceryUtilities.adjustUPCItemCost(items[2], 10); This should reduce the price of item[2] by 10%. The resulting cost will be: 2.34 If instead, I passed in (items[2], 5), the resulting cost will be: 2.47 METHOD TWO method getAllItemsForLoyaltyDeal will take an array of Groceryltem and a LoyaltyDeal object. The method will return an array of grocery items that have that loyalty deal. In other words, if the loyalty deal's UPC matches the grocery item's loyaltyCode that item will be added to the array that is returned from this method. For example: GroceryItem[] dealItems = GroceryUtilities.getALlItemsForLoyaltyDeal (items, lovals[0]); This method should return an array with two items: The item with UPC 400 (Cupcakes) and the item with UPC 700 (Swiss Cheese). Those items both have a loyalty code that matches the UPC of that loyalty deal. If I passed in loyals[3], the method would return an array with only one item: The item with UPC 501 (Corn Flakes). Next, add TWO MORE METHODS_to GrocecxUtilies class: METHOD THREE public static HashSet

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