I'm having some real trouble rearranging this equation to give me a absolute restricted value.
Basically, the purpose of the calculation is for a user making a call of a 'requested' duration to be reassigned a new duration based on the credit they have available.
The first 120secs of each call have a higher tariff rate than those thereafter (and this call is more than 120 secs in this instance) I've been using:
Duration = 400secs and CreditAvailable = 900cents at HighRate = 4.3c and LowRate = 2.3 for the low rate
else if(Duration > 120 && CreditAvailable < (lRate * (Duration - 120) + (120 * hRate))) //NOT WORKING AS OF 24.10!!!!
NewDuration = (double)Duration;
CallDiff = ((Duration - 120) * lRate) + (hRate * 120) - CreditAvailable;
NewDuration = ------Trying to work this part out;
Duration = (int)NewDuration;
CreditUsed = (lRate * (Duration - 120)) + (hRate * 120);
CreditAvailable = CreditAvailable - CreditUsed;
As you can see I don't have much, the bit above calculating CallDiff just calculates the difference between the Cost for the entered duration and the actual credit available to make the call.
What I want to make the new duration hold is the reduced duration to call within the credit available's limits
Could anyone help me work this out, I assume that I need to pass the difference through but I don't know where to start.
Any help would be greatly appreciated