44 lines
1.1 KiB
Text
44 lines
1.1 KiB
Text
include xpllib; \for Big ops and StrCopy
|
|
def Size=30;
|
|
char NumA(Size), NumB(Size), NumC(Size);
|
|
|
|
proc DolOut(Num); \Display Big Num as dollars and cents
|
|
char Num;
|
|
int LZ, I, Dig;
|
|
[LZ:= true; \suppress leading zeros
|
|
for I:= 0 to -1>>1 do
|
|
[if I+2 < Size then
|
|
if Num(I+2) = 0 then
|
|
[ChOut(0, ^.);
|
|
LZ:= false;
|
|
];
|
|
Dig:= Num(I);
|
|
if Dig = 0 then return;
|
|
if Dig # ^0 then LZ:= false;
|
|
if not LZ then ChOut(0, Dig);
|
|
];
|
|
];
|
|
|
|
[Int2Big(0, NumA, Size-1); \4e15
|
|
NumA(Size-1-16):= ^4;
|
|
Int2Big(550, NumB, Size-1); \* 5.50
|
|
BigMul(NumA, NumB);
|
|
|
|
Int2Big(286*2, NumB, Size-1); \+ 2*2.86
|
|
BigAdd(NumA, NumB);
|
|
Text(0, "Total price before tax : ");
|
|
DolOut(NumA); CrLf(0);
|
|
StrCopy(NumC, NumA); \save sub-total
|
|
|
|
Int2Big(765, NumB, Size-1); \* 7.65% tax
|
|
BigMul(NumA, NumB);
|
|
Int2Big(5000, NumB, Size-1); \round up
|
|
BigAdd(NumA, NumB);
|
|
BigDiv(NumA, 10_000); \truncate
|
|
Text(0, "Tax : ");
|
|
DolOut(NumA); CrLf(0);
|
|
|
|
BigAdd(NumA, NumC); \total = tax + sub-total
|
|
Text(0, "Total price after tax : ");
|
|
DolOut(NumA); CrLf(0);
|
|
]
|