Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

13.2 KB
Raw Blame
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Taxes and Fees — Elementary Mathematics</title><link rel="stylesheet" href="../lib/engine.css"><link rel="expect" href="#bar" blocking="render"><style>.band .prompt{font-size:27px}.screen .blanks .bline{gap:12px}.screen .blanks .box{width:8ch!important}.screen .blanks .why{font-size:21px}.screen .blanks .bline svg tspan{font-style:normal}</style></head><body>
<script src="../lib/engine.js"></script><script src="audio/en/timings.js"></script><script>
'use strict';
const CHAPTER={number:21,title:'Taxes and Fees',minutes:9,language:'en', next: '../ch22/' };
// Colours: chalk = original price, pink (rat) = tax/fee amount, amber = rate, blue = total.
const TAX=COL.rat,TOT=COL.whole;
const txText=(p,s,x,y,t=0,size=30,col=COL.chalk,anchor='start')=>{const e=T(p,s,{x,y,size,fill:col,anchor,o:0});show(e,t);return e;};
const txMath=(p,s,x,y,t=0,size=52,col=COL.chalk)=>{const e=M(p,Array.isArray(s)?s:[s],{x,y,size,fill:col,anchor:'middle',o:0});show(e,t);return e;};
const txTitle=(p,s,sub='')=>{txText(p,s,100,110,.1,43);if(sub)txText(p,sub,100,165,.15,27,COL.dim);};
// price strip at u px per dollar; tax/fee segment (pink) beside it at the same scale
function txBar(p,x,y,u,price,extra,t=0,h=100){const g=G(p,{x,y,o:0});g.dataset.price=String(price);g.dataset.extra=String(extra);const pr=mk('rect',{width:price*u,height:h,fill:COL.chalk,'fill-opacity':.14,stroke:COL.chalk,'stroke-width':3},g);const ex=mk('rect',{x:price*u,width:extra*u,height:h,fill:TAX,'fill-opacity':.7,stroke:TAX,'stroke-width':3},g);show(g,t);return {g,pr,ex,w:(price+extra)*u};}
function txChoices(p,items,u,hideTotal){return items.map(([price,tax,total],i)=>{const x=140+i*480,g=G(p),b=txBar(g,x,360,u,price,tax,0,100);txText(g,String.fromCharCode(65+i),x+190,270,0,34,COL.dim,'middle');txText(g,'price $'+price,x,330,0,28);txText(g,'+ tax $'+tax,x,500,0,29,TAX);txText(g,hideTotal?'= total ?':'= total $'+total,x,550,0,31,TOT);return {el:g,box:[x-20,235,430,360],label:'Picture '+String.fromCharCode(65+i)+', price '+price+', tax '+tax+(hideTotal?'':', total '+total),bar:b};});}
const BEATS=[
['intro','Taxes and Fees',(m,D)=>{const g=G(scene,{o:0,y:24});T(g,'Unit 2 · Ratios, Proportions, and Percents · Chapter 21',{x:800,y:195,size:28,fill:COL.dim,anchor:'middle'});T(g,'Taxes and Fees',{x:800,y:390,size:90,weight:600,anchor:'middle'});T(g,'extra = rate × price',{x:800,y:560,size:50,fill:COL.task,anchor:'middle'});tw(g,{o:1,y:0},.2,1,out);txText(g,'Find the extra · or work back to the price',800,720,m('sub'),35,COL.dim,'middle');hide(g,D-.8,.7);}],
['rate','Sales tax is a percent',m=>{const p=panel(0);txTitle(p,'Sales tax: a percent of the price','One dollar = 100 cents · drawn as 100 equal cells');const g=G(p,{x:160,y:230,o:0}),pk=G(g,{o:0});for(let i=0;i<100;i++){const a={x:(i%10)*34,y:Math.floor(i/10)*34,width:34,height:34};if(i<8)mk('rect',{...a,fill:TAX,'fill-opacity':.75},pk);mk('rect',{...a,fill:'none',stroke:COL.dim,'stroke-width':1.5},g);}show(g,m('eight',2));show(pk,m('eight',5.5));txText(p,'$1 = 100¢',330,625,m('eight',2),36,COL.chalk,'middle');txText(p,'8 of the 100 cents are tax',330,675,m('eight',5.5),31,TAX,'middle');txText(p,'sales tax',700,300,m('sales'),46,COL.task);txText(p,'8%',915,300,m('eight'),46,COL.task);txText(p,'8¢ extra for every 100¢',700,375,m('forms'),34);txMath(p,['8%  =  8:100  =  ',F('8','100'),'  =  0.08'],1060,520,m('forms',4.3),52,COL.task);txText(p,'rates differ by state and city · the rate stays fixed as prices change',1060,650,m('forms',13),27,COL.dim,'middle');}],
['dollars','Tax on every dollar',m=>{const p=panel(0);txTitle(p,'A $40 sweater · 8% sales tax','Each chip = $1');const g=G(p,{o:0}),sl=[],hl=[];for(let i=0;i<40;i++){const x=130+(i%10)*78,y=230+Math.floor(i/10)*96,c=G(g,{x,y});mk('rect',{width:64,height:64,fill:COL.chalk,'fill-opacity':.14,stroke:COL.chalk,'stroke-width':2},c);const s=mk('rect',{x:65,width:64*.08,height:64,fill:TAX},c);put(s,{o:0});sl.push(s);const h=mk('rect',{x:-4,y:-4,width:78,height:72,fill:'none',stroke:COL.task,'stroke-width':3},c);put(h,{o:0});hl.push(h);}
show(g,m('price'));sl.forEach(s=>show(s,m('each'),.5));
const cnt=txText(p,'tax so far: 0¢',980,400,m('count'),44,TAX);prog(q=>{const n=Math.floor(q*40+1e-8);hl.forEach((h,i)=>put(h,{o:i<n?1:0}));cnt.textContent='tax so far: '+n*8+'¢';},m('count'),5,lin);
txText(p,'40 × 8¢ = 320¢ = $3.20',980,510,m('result'),44,TAX);txText(p,'more dollars, more tax: same rate each dollar',980,585,m('result',6.8),27,COL.dim);}],
['method1','Method 1: multiply',m=>{const p=panel(0);txTitle(p,'Method 1 · multiply by the decimal rate','The tax is 8% of the price');const b=txBar(p,160,260,22,40,3.2);txText(p,'price $40',160+440,395,0,32,COL.chalk,'middle');txText(p,'tax',160+880+35,235,m('bar'),30,TAX,'middle');put(b.ex,{o:0});show(b.ex,m('bar'));txMath(p,'8% = 0.08',800,520,m('convert'),52,COL.task);txMath(p,'40 × 0.08 = 3.2',800,640,m('product'),60);txText(p,'tax = $3.20 · money gets two decimal places',800,780,m('money'),38,TAX,'middle');}],
['method2','Method 2: proportion',m=>{const p=panel(0);txTitle(p,'Method 2 · same ratio, two prices','Both strips use the same scale');txBar(p,160,230,9,100,8,0,70);txText(p,'price $100 · tax $8',160+486,335,m('top'),30,COL.chalk,'middle');txBar(p,160,370,9,40,3.2,0,70);txText(p,'price $40 · tax x',160+194,475,m('bottom'),30,COL.chalk,'middle');txMath(p,[F('8','100'),' = ',F('x','40')],800,610,m('equation'),62);txMath(p,'100x = 320',800,730,m('cross'),56);txMath(p,'x = 3.2',800,825,m('answer'),56,TAX);txText(p,'= $3.20',935,825,m('answer',3.9),44,TAX);}],
['methods','Method 3 and a check',m=>{const p=panel(0);txTitle(p,'Three methods · one answer','Pick one, check with another');[['Multiply',['40 × 0.08 = 3.2'],.3,.5],['Proportion',[F('8','100'),' = ',F('x','40'),' → x = 3.2'],.3,.5],['Equation: “What is 8% of $40?”',['x = 0.08 × 40 = 3.2'],m('ask'),m('eq')]].forEach(([lab,eq,tl,te],i)=>{txText(p,lab,150,300+i*150,tl,32,COL.dim);txMath(p,eq,420,375+i*150,te,56);txText(p,'$3.20',1350,375+i*150,m('same',1+i*.5),50,TAX,'middle');});}],
['q1','Total with tax',()=>{const p=panel(0);txTitle(p,'A $50 game · 6% sales tax','All strips use the same scale: 5 px = $1');S.txCh=txChoices(p,[[50,3,53],[50,6,56],[50,30,80]],5);},{ask:done=>quiz(BAND,[{id:'c-total',prompt:'Which picture shows the total price of the game?',build:pickEls(S.txCh,0,'0.06 × 50 = 3, so the total is $53.',i=>i===1?'$6 treats 6% as 6 dollars. 6% of $50 is only $3.':'$30 would be 60% of $50. 6% is 0.06 × 50 = $3.')}],done)}],
['total','Price plus tax',m=>{const p=panel(0);txTitle(p,'What do you pay?','price + tax = total');const b=txBar(p,160,260,22,40,3.2);txText(p,'price $40',160+440,395,0,32,COL.chalk,'middle');txText(p,'tax $3.20',160+880+35,235,0,30,TAX,'middle');txMath(p,'40 + 3.20 = 43.20',800,600,m('add'),58,TOT);const br=path(p,'M160 420V440H1110.4V420',{stroke:TOT,'stroke-width':3,fill:'none'},{d:0});draw(br,m('pct'),.8);txText(p,'total = 100% + 8% = 108% of the price',635,488,m('pct'),34,TOT,'middle');txMath(p,'1.08 × 40 = 43.20',800,710,m('one'),58,TOT);txText(p,'one step: (1 + rate) × price',800,800,m('one',1),32,COL.dim,'middle');}],
['original','Work back to the price',m=>{const p=panel(0);txTitle(p,'Total $53.99 · 8% tax included','What was the price before tax?');txBar(p,160,255,18,49.99,4);txText(p,'original price p = 100%',160+450,390,m('pct'),32,COL.chalk,'middle');txText(p,'tax 8%',160+900+36,230,m('pct'),30,TAX,'middle');draw(path(p,'M160 410V428H1131.8V410',{stroke:TOT,'stroke-width':3,fill:'none'},{d:0}),m('receipt'),.8);txText(p,'total $53.99',640,472,m('receipt'),38,TOT,'end');txText(p,'= 108%',650,472,m('pct'),38,TOT);txMath(p,'100% + 8% = 108% = 1.08',800,560,m('pct',1),46,COL.task);txMath(p,'53.99 = 1.08 × p',800,645,m('eq'),56);txMath(p,'p = 53.99 ÷ 1.08 ≈ 49.99',800,735,m('divide'),56,COL.chalk);txText(p,'check: 1.08 × 49.99 = 53.9892 ≈ 53.99',800,822,m('check'),33,COL.dim,'middle');}],
['mistake','Tax is of the original',m=>{const p=panel(0);txTitle(p,'A tempting shortcut','Subtract 8% of the total?');txMath(p,'53.99 − 0.08 × 53.99 ≈ 49.67',800,330,m('wrong'),54);const x=path(p,'M270 360L1330 300',{stroke:COL.bad,'stroke-width':6},{d:0});draw(x,m('why'),.6);txText(p,'The tax was 8% of the original price, not of the total.',800,470,m('why'),34,COL.task,'middle');txText(p,'test: tax on $49.67 ≈ $3.97 → total $53.64, not $53.99',800,570,m('test'),34,COL.dim,'middle');txMath(p,'p = 53.99 ÷ 1.08 ≈ 49.99',800,735,m('right'),58,TOT);}],
['q2','Which price?',()=>{const p=panel(0);txTitle(p,'The total is $54.00 · 8% tax','Same scale: 4 px = $1');S.txCh=txChoices(p,[[49.68,3.97,'53.65'],[50,4,'54.00'],[58.32,4.67,'62.99']],4,true);},{ask:done=>quiz(BAND,[{id:'c-orig',prompt:'Which original price gives a total of $54.00?',build:pickEls(S.txCh,1,'54 ÷ 1.08 = 50, and 1.08 × 50 = 54.',i=>i===0?'That subtracts 8% of the total. Its own tax is $3.97, so the total is only $53.65.':'That multiplies the total by 1.08, going the wrong way. Its total would be $62.99.')}],done)}],
['fee','Fees are percents too',m=>{const p=panel(0);txTitle(p,'Bike rental: $65 · 17% late fee','A fee works like a tax');const b=txBar(p,160,260,16,65,11.05);put(b.ex,{o:0});show(b.ex,m('fee'));txText(p,'rental $65',160+520,395,m('bike'),32,COL.chalk,'middle');txText(p,'late fee',160+1040+88,235,m('fee'),30,TAX,'middle');txMath(p,'17% = 0.17',800,520,m('rate'),50,COL.task);txMath(p,'0.17 × 65 = 11.05',800,625,m('fee'),56,TAX);txMath(p,'65 + 11.05 = 76.05',800,735,m('total'),58,TOT);txText(p,'late fee $11.05 · total $76.05',800,830,m('total',1.5),34,COL.dim,'middle');}],
['feeorig','Work back from a fee',m=>{const p=panel(0);txTitle(p,'Snowboard: total $66.08 · 12% fee included','What was the rental price?');txBar(p,160,255,18,59,7.08);txText(p,'rental price p = 100%',160+531,390,m('pct'),32,COL.chalk,'middle');txText(p,'fee 12%',160+1062+64,230,m('pct'),30,TAX,'middle');draw(path(p,'M160 410V428H1349.4V410',{stroke:TOT,'stroke-width':3,fill:'none'},{d:0}),m('receipt'),.8);txText(p,'total $66.08',740,472,m('receipt'),38,TOT,'end');txText(p,'= 112%',750,472,m('pct'),38,TOT);txMath(p,'100% + 12% = 112% = 1.12',800,560,m('pct',1),46,COL.task);txMath(p,'66.08 = 1.12 × p',800,645,m('pct',5.5),56);txMath(p,'p = 66.08 ÷ 1.12 = 59',800,735,m('divide'),56);txText(p,'check: 0.12 × 59 = 7.08 and 59 + 7.08 = 66.08',800,822,m('check'),33,COL.dim,'middle');}],
['q3','Fee and total',()=>{const p=panel(0);txTitle(p,'A $45 charge · 20% service fee','Strip: price + fee, to scale');txBar(p,160,260,16,45,9);txText(p,'price $45',160+360,395,0,32,COL.chalk,'middle');txText(p,'fee ?',160+720+72,235,0,30,TAX,'middle');},{ask:done=>quiz(BAND,[{id:'c-fee',prompt:'Find the fee and the total in dollars.',build:blanks([{parts:['fee $',{box:'9'},'     total $',{box:'54'}],why:'0.20 × 45 = 9, and 45 + 9 = 54 (or 1.20 × 45).'}])}],done)}],
['wrap','Four habits',m=>{const p=panel(0);txTitle(p,'Taxes and fees · the same percent idea');[['A tax or fee is a percent of the original price.','w1'],['Extra = rate × price. Total = price + extra = (1 + rate) × price.','w2'],['Know the total? Divide by (1 + rate) to get the original price.','w3'],['Round money to the cent; check by building the total forward.','w4']].forEach(([s,key],i)=>{const g=G(p,{x:-16,y:285+i*145,o:0});mk('circle',{cx:130,cy:-10,r:26,fill:COL.task},g);T(g,String(i+1),{x:130,y:0,size:30,anchor:'middle',fill:COL.board});T(g,s,{x:195,size:31});tw(g,{x:0,o:1},m(key),.6);});}],
['final1','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-tax',prompt:'Find the tax. Round to the nearest cent; type only the number.',build:blanks([
{parts:['8% tax on $12.00 = $',{box:'0.96'}],why:'0.08 × 12 = 0.96.'},
{parts:['8.5% tax on $12.00 = $',{box:'1.02'}],why:'0.085 × 12 = 1.02.'},
{parts:['9.25% tax on $27.50 = $',{box:'2.54'}],why:'0.0925 × 27.50 = 2.54375, which rounds to 2.54.'},
{parts:['8% tax on $234.25 = $',{box:'18.74'}],why:'0.08 × 234.25 = 18.74.'}
])}],done,'Chapter practice · set 1 of 3')}],
['final2','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-total',prompt:'Totals and original prices. Round to the nearest cent; type only the number.',build:blanks([
{parts:['Total with 8.5% tax on $27.50 = $',{box:'29.84'}],why:'27.50 + 2.34 = 29.84, or 1.085 × 27.50 rounded.'},
{parts:['Total $11.65 includes 6% tax. Original price = $',{box:'10.99'}],why:'11.65 ÷ 1.06 ≈ 10.99.'},
{parts:['Total $21.80 includes 9% tax. Original price = $',{box:'20'}],why:'21.80 ÷ 1.09 = 20.'},
{parts:['Total $63 includes 5% tax. Original price = $',{box:'60'}],why:'63 ÷ 1.05 = 60.'}
])}],done,'Chapter practice · set 2 of 3')}],
['final3','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-fee',prompt:'Fees. Type only the number of dollars.',build:blanks([
{parts:['15% late fee on an $80 rental = $',{box:'12'}],why:'0.15 × 80 = 12.'},
{parts:['Total with a 20% fee on a $45 charge = $',{box:'54'}],why:'1.20 × 45 = 54.'},
{parts:['Total $66.08 includes a 12% fee. Original price = $',{box:'59'}],why:'66.08 ÷ 1.12 = 59.'},
{parts:['Total $45 includes a 25% fee. Original price = $',{box:'36'}],why:'45 ÷ 1.25 = 36.'}
])}],done,'Chapter practice · set 3 of 3')}],
['finish','Finished',()=>panel(0),{ask:finishCard}]
].map(([id,title,run,extra])=>({id,title,run,...extra}));
boot();
</script></body></html>