Price fraction: Difference between revisions
Content added Content deleted
mNo edit summary |
(Rename variable) |
||
Line 2,234: | Line 2,234: | ||
const func float: computePrice (in float: x) is func |
const func float: computePrice (in float: x) is func |
||
result |
result |
||
var float: |
var float: price is 0.0; |
||
begin |
begin |
||
if x >= 0.0 and x < 0.06 then |
if x >= 0.0 and x < 0.06 then |
||
price := 0.10; |
|||
elsif x < 0.11 then |
elsif x < 0.11 then |
||
price := 0.18; |
|||
elsif x < 0.36 then |
elsif x < 0.36 then |
||
price := flt(((trunc(x * 100.0) - 11) div 5) * 6 + 26) / 100.0; |
|||
elsif x < 0.96 then |
elsif x < 0.96 then |
||
price := flt(((trunc(x * 100.0) - 31) div 5) * 4 + 50) / 100.0; |
|||
else |
else |
||
price := 1.0; |
|||
end if; |
end if; |
||
end func; |
end func; |
||
Line 2,267: | Line 2,267: | ||
const func float: computePrice (in float: x) is func |
const func float: computePrice (in float: x) is func |
||
result |
result |
||
var float: |
var float: price is 0.0; |
||
local |
local |
||
var integer: index is 1; |
var integer: index is 1; |
||
Line 2,275: | Line 2,275: | ||
incr(index); |
incr(index); |
||
end while; |
end while; |
||
price := table[index][2]; |
|||
else |
else |
||
raise RANGE_ERROR; |
raise RANGE_ERROR; |