## Problem Statement | |||||||||||||

PROBLEM STATEMENT: Class name: HoldCost Method name: calcHoldCost Parameters: int[], int, int, int Returns: int Material Requirements Planning is a process that plans out the production of a product based on a sales forecast. An optimal production schedule helps lower the costs of production. One key concept to this is holding costs. Holding costs represent the cost of holding one unit for one period of time (such as weekly, monthly or quarterly). Implement a class HoldCost, which contains a method calcHoldCost. The method returns the sum of monthly holding costs given a twelve month requirements schedule (number of units required each month), an initial inventory level, the number of units produced per month and the holding cost per unit per month. The method signature is: int calcHoldCost(int[] requirements, int initialInventory, int prodPerMonth, int holdingCostPerUnit); Be sure your method is public. To calculate the holding cost for each month: Inventory for the month = prior months inventory + production for the current month - requirement for the current month Holding Cost = (Inventory from "prior" month) * holdingCostPerUnit TopCoder will ensure the validity of the inputs. Inputs are valid if all of the following criteria are met: *The requirements int[] will contain twelve months of information (twelve entries). Month one will be index zero, month two will be index one, etc. *Each requirement element will be an int between 0 and 1000 (inclusive) *The initialInventory represents the inventory prior to month one *The initialInventory will be an int between 0 and 1000 (inclusive) *The prodPerMonth will be an int between 0 and 1000 (inclusive) *The holdingCostPerUnit will be an int between 1 and 100 (inclusive) Notes: *Negative inventory levels should NOT be carried forward (see example below) Examples: --An input of ({110,70,40,20,10,100,15,40,120,70,10,80},70,50,15) would be calculated as follows: Month 1's holding cost would be 70 (initialInv) * 15 = 1050 Month 1's inventory level would be 70+50-110 = 10 Total holding cost thus far = 0 (since there is no total holding cost yet) + 1050 = 1050 Month 2's holding cost would be 10 (month 1 inventory) * 15 = 150 Month 2's inventory level would be 10+50-70 = -10 Total holding cost thus far = 1050 + 150 = 1200 Month 3's holding cost would be 0 (because there is a negative inventory level) Month 3's inventory level would be 0 (previous month had a negative inventory) + 50 - 40 = 10 Total holding cost thus far = 1200 + 0 = 1200 ... etc ... Month 12's holding cost would be 40 (month 11's inventory) * 15 = 600 Month 12's inventory level would be 40 + 50 - 80 = 10 Total holding cost thus far = 5775 + 600 = 6375 The method then returns 6375 -- An input of ({10,10,10,10,10,10,10,10,10,10,10,10},0,0,15) would return 0 -- An input of ({10,10,10,10,10,10,10,10,10,10,10,10},10,10,15) would return 1800 -- An input of ({40,50,60,40,50,60,40,50,60,40,50,60},0,50,10) would return 800 | |||||||||||||

## Definition | |||||||||||||

| |||||||||||||