Price fraction: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added DO-END and SELECT labels. -- ~~~~)
Line 1,842: Line 1,842:


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX program to rescale a price (0.99 --> 1.00). */
<lang rexx>
do j=0 to 1 by .01
/*REXX program to rescale a price (0.99 --> 1.00). */
if j=0 then j=0.00

say 'original price-->'j " " adjustPrice(j) '<-- adjusted price'
do j=0 to 1 by .01
if j=0 then j=0.00
end /*j*/
say 'original price-->'j " " adjustPrice(j) '<-- adjusted price'
end

exit
exit
/*------------------------------------------------------------------*/


adjustPrice: procedure; parse arg x
adjustPrice: procedure; parse arg x
select

when x<0.06 then x=0.10
select
when x<0.06 then x=0.10
when x<0.11 then x=0.18
when x<0.11 then x=0.18
when x<0.16 then x=0.26
when x<0.16 then x=0.26
when x<0.21 then x=0.32
when x<0.21 then x=0.32
when x<0.26 then x=0.38
when x<0.26 then x=0.38
when x<0.31 then x=0.44
when x<0.31 then x=0.44
when x<0.36 then x=0.50
when x<0.36 then x=0.50
when x<0.41 then x=0.54
when x<0.41 then x=0.54
when x<0.46 then x=0.58
when x<0.46 then x=0.58
when x<0.51 then x=0.62
when x<0.51 then x=0.62
when x<0.56 then x=0.66
when x<0.56 then x=0.66
when x<0.61 then x=0.70
when x<0.61 then x=0.70
when x<0.66 then x=0.74
when x<0.66 then x=0.74
when x<0.71 then x=0.78
when x<0.71 then x=0.78
when x<0.76 then x=0.82
when x<0.76 then x=0.82
when x<0.81 then x=0.86
when x<0.81 then x=0.86
when x<0.86 then x=0.90
when x<0.86 then x=0.90
when x<0.91 then x=0.94
when x<0.91 then x=0.94
when x<0.96 then x=0.98
when x<0.96 then x=0.98
when x<1.01 then x=1.00
otherwise nop
when x<1.01 then x=1.00
end /*select*/
otherwise nop
return x</lang>
end
'''output'''

return x
</lang>
Output:
<pre style="height:30ex;overflow:scroll">
<pre style="height:30ex;overflow:scroll">
original price-->0.00 0.10 <-- adjusted price
original price-->0.00 0.10 <-- adjusted price