Copy link to clipboard
Copied
I am a newer programmer and I am not sure I would translate this into code..
If the time is between 21-30 days, the cost is $50. If it is more than 30 days, there is an additional charge of $34 for each additional month.
31-60 days would calculate at 84,
61-90 days would calculate at 118
and so on.
Thanks!
Copy link to clipboard
Copied
Something like this? Firstly, a loop to demonstrate we're getting the correct value on every day
<cfset cost = 50>
<cfloop index="day" from="21" to="120">
<cfset extraCost = ((day-1) \ 30) * 34>
<cfoutput>
#day# days, #extraCost + cost#<br>
</cfoutput>
</cfloop>
Then probably something more like the code you'll need
<cfset days = 61> <!--- or whatever --->
<cfset newCost = (((days-1) \ 30) * 34) + 50>
<cfoutput>#newCost#</cfoutput>
Copy link to clipboard
Copied
Worked! (actually I didn't try the loop, just the bottom part worked). Thank you!
Copy link to clipboard
Copied
Just be mindful that "a month" is not a set amount of time. It can range from 29-31 days.
Copy link to clipboard
Copied
Indeed. My work says they want it set for 30 days but "That might change". So good for now at least!