Price fraction: Difference between revisions

m
→‎version 1: added a comment, changed whitespace, used a different output template, split a compound statement.
m (→‎version 1: added a comment, changed whitespace, used a different output template, split a compound statement.)
Line 2,998:
=={{header|REXX}}==
===version 1===
<lang rexx>/*REXX program to rescalere─scales a (decimal fraction) price (in the range of: (0.99 ──► 1.00).*/
pad= ' ' /*for inserting spaces into msga message. */
do j=0 to 1 by .01; if j==0 then j=0.00 /*specialprocess the prices from 0¢ to ≤ $1 case.*/
if j==0 then j= 0.00 /*handle the special case of zero cents*/
say pad 'original price ──►' j pad adjPrice(j) " ◄── adjusted price"
end /*j*/
exit end /*stick a fork in it, we're done.j*/
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────ADJPRICE subroutine─────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
adjPrice: procedure; parse arg ?
adjPrice: procedure; parse arg ? /*a table is used to facilitate changes*/
select
when ?<0.06 then ?=0.10 select
when ?<0.1106 then ?= 0.1810
when ?<0.1611 then ?= 0.2618
when ?<0.2116 then ?= 0.3226
when ?<0.2621 then ?= 0.3832
when ?<0.3126 then ?= 0.4438
when ?<0.3631 then ?= 0.5044
when ?<0.4136 then ?= 0.5450
when ?<0.4641 then ?= 0.5854
when ?<0.5146 then ?= 0.6258
when ?<0.5651 then ?= 0.6662
when ?<0.6156 then ?= 0.7066
when ?<0.6661 then ?= 0.7470
when ?<0.7166 then ?= 0.7874
when ?<0.7671 then ?= 0.8278
when ?<0.8176 then ?= 0.8682
when ?<0.8681 then ?= 0.9086
when ?<0.9186 then ?= 0.9490
when ?<0.9691 then ?= 0.9894
when ?<10.0196 then ?=1 0.0098
otherwise nop when ?<1.01 then ?= 1.00
end /*select*/ otherwise nop
end /*select*/
return ?</lang>
{{out}}
{{out|output|text=:}}
<pre style="height:30ex66ex">
original price ──► 0.00 0.10 ◄── adjusted price
original price ──► 0.01 0.10 ◄── adjusted price