Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Currency/Zkl/currency-1.zkl
Normal file
26
Task/Currency/Zkl/currency-1.zkl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
var priceList=Dictionary("hamburger",550, "milkshake",286);
|
||||
var taxRate=765; // percent*M
|
||||
const M=0d10_000;
|
||||
|
||||
fcn toBucks(n){ "$%,d.%02d".fmt(n.divr(100).xplode()) }
|
||||
fcn taxIt(n) { d,c:=n.divr(M).apply('*(taxRate)); d + (c+5000)/M; }
|
||||
fcn calcTab(items){ // (hamburger,15), (milkshake,100) ...
|
||||
items=vm.arglist;
|
||||
fmt:="%-10s %8s %18s %26s";
|
||||
fmt.fmt("Item Price Quantity Extension".split().xplode()).println();
|
||||
|
||||
totalBeforeTax:=0;
|
||||
foreach item,n in (items.sort(fcn(a,b){ a[0]<b[0] })){
|
||||
price:=priceList[item]; t:=price*n;
|
||||
fmt.fmt(item,toBucks(price),n,toBucks(t)).println();
|
||||
totalBeforeTax+=t;
|
||||
}
|
||||
fmt.fmt("","","","--------------------").println();
|
||||
fmt.fmt("","","subtotal",toBucks(totalBeforeTax)).println();
|
||||
|
||||
tax:=taxIt(totalBeforeTax);
|
||||
fmt.fmt("","","Tax",toBucks(tax)).println();
|
||||
|
||||
fmt.fmt("","","","--------------------").println();
|
||||
fmt.fmt("","","Total",toBucks(totalBeforeTax + tax)).println();
|
||||
}
|
||||
1
Task/Currency/Zkl/currency-2.zkl
Normal file
1
Task/Currency/Zkl/currency-2.zkl
Normal file
|
|
@ -0,0 +1 @@
|
|||
calcTab(T("milkshake",2),T("hamburger",4000000000000000));
|
||||
Loading…
Add table
Add a link
Reference in a new issue