Currency: Difference between revisions
→{{header|J}}: Create bill using verb
(→{{header|J}}: Create bill using verb) |
|||
Line 675:
<lang j>require 'format/printf'
Quantities=: 4000000000000000 2
▲Items=: ;: 'Hamburger Milkshake'
Tax_rate=: x: 0.0765
Tax=: Tax_rate * Subtotal▼
'items prices quantities'=. y
values=. prices * quantities
subtotal=. +/ values
-------------------------------▼
total=. subtotal + tax
'%9s %8s %20s %22s' printf ;:'Item Price Quantity Value'
'%9s %8.2f %20d %22.2f' printf"1 items ,. <"0 prices ,. quantities ,. values
'%40s %21.2f' printf"1 (;:'Subtotal: Tax: Total:') ,. subtotal;tax;total
)
makeBill Items;Prices;Quantities</lang>
{{out}}
<pre>
Hamburger 5.50 4000000000000000 22000000000000000.00
Milkshake 2.86 2 5.72
|