double cost1 = 0, cost2= 0; for( weight = 0; weight<=free_weight; weigh++) { cost 1 = getMinimumCost(); } for( weight = 11; weight<=weight_limit; weigh++) { cost2 +=weight * getRate20(); }

Here is what I am trying to do. I am given a certain weight for a shipping carrier. i need to throw that weight through three ranges and it needs to individually calculate the cost for each range as long as the weight is in that range and then calculates the total of any applicable ranges.

For ex. the ranges are for zone1, zone2, zone3 are 0-10, 11-20 , 21-75, respectively. The rates for each zone are 0, $2, $3 / extra pound respectively.

So for instance, for a 25 pound object, it would be the minimum cost, $9.25 + (10 * 2) + (5 * 3).

i am trying to setup a for loop for each of those ranges but i don't know where I am going wrong here as free_weight and weight_limit are predefined variables so using those in the for loop would only mean i'd get the maximum cost for that range rather then the actual cost given a specific weight