(Solved) : 9 Restocking Warehouse Purchasing Manager Must Buy Specific Number Units Item Replenish Wa Q41638194 . . .

9. Restocking the Warehouse A purchasing manager must buy a specific number of units of an item to replenish the warehouse. T

Input Format For Custom Testing The first line contains an integer, n, the number of items needed Each line i of the n subseq

9. Restocking the Warehouse A purchasing manager must buy a specific number of units of an item to replenish the warehouse. The primary supplier has a list of containers, each with a number of units. The manager must buy contiguous containers, starting at container 0 and continuing until at least the desired number have been purchased. If there are not enough units available, they must be purchased from another supplier. If any excess items must be purchased, they must be resold. Determine the remaining number of items to be purchased or sold after purchasing from the primary supplier. Example itemCount = [10, 20, 30, 40, 15) target = 80 The manager starts buying at index 0 and continues until all available units are purchased or until at least 80 units have been purchased. The manager will buy containers with itemCounts = 10 + 20 + 30 + 40 = 100. Since too many items were purchased, the number sold is purchased – target = 100 – 80 = 20 units. If the target = 130, the manager will purchase all of the units from the primary supplier for a total of purchases = 115. Then another target – purchases = 130 – 115 = 15 additional units must be purchased. Function Description Complete the function restock in the editor below. The function must return the number of units that must be resold or that must be purchased from an alternate supplier. restock has the following parameter(s): itemCount[itemCount[O]….itemCount[n-1]]: an array of integers that denote the item counts of the each container in the order they must be purchased target: an integer that denotes the target number of items needed Constraints • 1sns 105 • 1 s target s 109 • 1 s itemCountil s 109 Input Format For Custom Testing The first line contains an integer, n, the number of items needed Each line i of the n subsequent lines (where 0 si<n) contains an integer, itemCount[l, the item count in the ith container The next line contains an integer, target, the target number of items needed Sample Case 0 Sample Input For Custom Testing 100 Sample Output 90 Explanation n = 4 itemCounts = 16, 1, 2, 1) target = 100 The number of items available at the primary supplier is 6 + 1 + 2 + 1 = 10 units. The manager must buy 100 – 10 = 90 additional units. Sample Case 1 Sample Input For Custom Testing Sample Output Explanation The number of items in the first 3 containers is 1 + 2 + 3 = 6. The purchasing manager must sell 6-4 = 2 units. Show transcribed image text 9. Restocking the Warehouse A purchasing manager must buy a specific number of units of an item to replenish the warehouse. The primary supplier has a list of containers, each with a number of units. The manager must buy contiguous containers, starting at container 0 and continuing until at least the desired number have been purchased. If there are not enough units available, they must be purchased from another supplier. If any excess items must be purchased, they must be resold. Determine the remaining number of items to be purchased or sold after purchasing from the primary supplier. Example itemCount = [10, 20, 30, 40, 15) target = 80 The manager starts buying at index 0 and continues until all available units are purchased or until at least 80 units have been purchased. The manager will buy containers with itemCounts = 10 + 20 + 30 + 40 = 100. Since too many items were purchased, the number sold is purchased – target = 100 – 80 = 20 units. If the target = 130, the manager will purchase all of the units from the primary supplier for a total of purchases = 115. Then another target – purchases = 130 – 115 = 15 additional units must be purchased. Function Description Complete the function restock in the editor below. The function must return the number of units that must be resold or that must be purchased from an alternate supplier. restock has the following parameter(s): itemCount[itemCount[O]….itemCount[n-1]]: an array of integers that denote the item counts of the each container in the order they must be purchased target: an integer that denotes the target number of items needed Constraints • 1sns 105 • 1 s target s 109 • 1 s itemCountil s 109
Input Format For Custom Testing The first line contains an integer, n, the number of items needed Each line i of the n subsequent lines (where 0 si

Expert Answer


Answer to 9. Restocking the Warehouse A purchasing manager must buy a specific number of units of an item to replenish the warehou…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?