Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Currency/REXX/currency-1.rexx
Normal file
29
Task/Currency/REXX/currency-1.rexx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*REXX program shows a method of computing the total price and tax for purchased items.*/
|
||||
numeric digits 200 /*support for gihugic numbers.*/
|
||||
taxRate= 7.65 /*number is: nn or nn% */
|
||||
if right(taxRate, 1)\=='%' then taxRate= taxRate / 100 /*handle plain tax rate number*/
|
||||
taxRate= strip(taxRate, , '%') /*strip the % (if present).*/
|
||||
item. =; items= 0 /*zero out the register. */
|
||||
item.1 = '4000000000000000 $5.50 hamburger' /*the first item purchased. */
|
||||
item.2 = ' 2 $2.86 milkshake' /* " second " " */
|
||||
say center('quantity', 22) center("item", 22) center('price', 22)
|
||||
hdr= center('', 27, "─") center('', 20, "─") center('', 27, "─")
|
||||
say hdr; total= 0
|
||||
do j=1 while item.j\=='' /*calculate the total and tax.*/
|
||||
parse var item.j quantity price thing /*ring up an item on register.*/
|
||||
items = items + quantity /*tally the number of items. */
|
||||
price = translate(price, , '$') /*maybe scrub out the $ symbol*/
|
||||
subtotal = quantity * price /*calculate the sub-total.*/
|
||||
total = total + subtotal /* " " running total.*/
|
||||
say right(quantity, 27) left(thing, 20) show$(subtotal)
|
||||
end /*j*/
|
||||
say /*display a blank line for separator. */
|
||||
say translate(hdr, '═', "─") /*display the separator part of the hdr*/
|
||||
tax= format(total * taxRate, , 2) /*round the total tax for all the items*/
|
||||
say right(items "(items)", 35) right('total=', 12) show$(total)
|
||||
say right('tax at' (taxRate * 100 / 1)"%=", 48) show$(tax)
|
||||
say
|
||||
say right('grand total=', 48) show$(total+tax)
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
show$: return right( '$'arg(1), 27) /*right─justify and format a number. */
|
||||
33
Task/Currency/REXX/currency-2.rexx
Normal file
33
Task/Currency/REXX/currency-2.rexx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*REXX program shows a method of computing the total price and tax for purchased items.*/
|
||||
numeric digits 200 /*support for gihugic numbers.*/
|
||||
taxRate= 7.65 /*number is: nn or nn% */
|
||||
if right(taxRate, 1)\=='%' then taxRate= taxRate / 100 /*handle plain tax rate number*/
|
||||
taxRate=strip(taxRate, , '%') /*strip the % (if present).*/
|
||||
item. =; items= 0 /*zero out the register. */
|
||||
item.1 = '4000000000000000 $5.50 hamburger' /*the first item purchased. */
|
||||
item.2 = ' 2 $2.86 milkshake' /* " second " " */
|
||||
say center('quantity', 22) center("item", 22) center('price', 22)
|
||||
hdr= center('', 27 ,"─") center('', 20, "─") center('', 27, "─")
|
||||
say hdr; total=0
|
||||
do j=1 while item.j\=='' /*calculate the total and tax.*/
|
||||
parse var item.j quantity price thing /*ring up an item on register.*/
|
||||
items = items + quantity /*tally the number of items. */
|
||||
price = translate(price, , '$') /*maybe scrub out the $ symbol*/
|
||||
subtotal = quantity * price /*calculate the sub-total.*/
|
||||
total = total + subtotal /* " " running total.*/
|
||||
say right(quantity, 27) left(thing, 20) show$(subtotal)
|
||||
end /*j*/
|
||||
say /*display a blank line for separator. */
|
||||
say translate(hdr, '═', "─") /*display the separator part of the hdr*/
|
||||
tax= format(total * taxRate, , 2) /*round the total tax for all the items*/
|
||||
say right( commas(items "(items)"), 35) right('total=', 12) show$(total)
|
||||
say right('tax at' (taxRate * 100 / 1)"%=", 48) show$(tax)
|
||||
say
|
||||
say right('grand total=', 48) show$(total + tax)
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
commas: procedure; parse arg _; n= _'.9'; #= 123456789; b= verify(n, #, "M")
|
||||
e= verify(n, #'0', , verify(n, #"0.", 'M') ) - 4 /* [↓] commatize number*/
|
||||
do j=e to b by -3; _= insert(',', _, j); end /*j*/; return _
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
show$: return right( commas( '$'arg(1) ), 27) /*right─justify and format a number. */
|
||||
Loading…
Add table
Add a link
Reference in a new issue