Question: java eclipse mapping problem Implement shoppingTotal * * Given two maps: * one containing the name of various items mapped to their cost and another

java eclipse mapping problem

Implement shoppingTotal * * Given two maps: * one containing the name of various items mapped to their cost and another * one containing a list of items mapped to their quantity * calculate the total cost of the whole order. * * return an int with the total cost. * * Example 1: * itemToCostMap: { Milk=3, Eggs=5, LaundryDetergent=15, GarbageCan=50} * itemToQuantityMap: {Milk=2, Eggs=1 } * return 11 Note: (2*3 +1*5) * * Example 2: * itemToCostMap: { Milk=3, Eggs=5, LaundryDetergent=15, GarbageCan=50} * itemToQuantityMap: {LaundryDetergent=3, GarbageCan=1 } * return 95 Note: (3*15 +1*50) * * Example 3: * itemToCostMap: { Milk=3, Eggs=5, LaundryDetergent=15, GarbageCan=50} * itemToQuantityMap: {} * return 0 * * * @param itemToCostMap - a HashMap where the key is the item name and the value is the cost * @param itemToQuantityMap - a HashMap where the key is the item name and the value is the quantity to buy * @return int - total cost of buying everything * * You may assume that all items in the itemToQuantityMap WILL be in the itemToCostMap * If there are no entries in the itemToQuantityMap, you should return 0. */ public static int calculateShoppingTotal(HashMap itemToCostMap, HashMap itemToQuantityMap) {

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!