In state S, whose currency is Din (D), two ways of paying taxes are under discussion. The progressive way, illustrated in the graph on the left:  up to 2000 D of annual income, no taxes are paid,  from 2000 to 4000 D you pay 10% of the part of it that exceeds 2000 D,  from 4000 to 5500 D you pay the same as those with an income of 4000 D plus 20% of the part that exceeds 4000 D,  over 5500 D you pay the same as those with an income of 5500 D plus 35% of the part that exceeds 5500 D.   The flat tax system is shown on the right:  up to 2000 D of annual income, no tax is paid, above 2000 D you pay 15% of the part of it that exceeds 2000 D.   How many taxes would those who have an annual income of 1500 D, 3000 D, 5000 D, 7000 D, 15000 D pay under the two systems?





 

The code:

<script language="javascript">
function Calcola() { r = document.Impo.r.value; if(r < 2000) document.Impo.t1.value = 0;
 if(r >= 2000 && r < 4000) document.Impo.t1.value = (r-2000)*10/100;
 if(r >= 4000 && r < 5500) document.Impo.t1.value = 200+(r-4000)*20/100;
 if(r >= 5500) document.Impo.t1.value = 500+(r-5500)*35/100;
 if(r < 2000) document.Impo.t2.value = 0; if(r >= 2000) document.Impo.t2.value = (r-2000)*15/100 }
</script>
<center><b>
Put the <i>Income</i>. Click and get '<i>Tax</i><br><br>
<form name="Impo">
Income =          <input type="text" name="r" value="" size=20> <br/><br/>
Progressive Tax = <input type="text" name="t1" value="" size=20><br/><br/>
Flat  Tax  =      <input type="text" name="t2" value="" size=20><br/><br/>
<input type="button" value="CLICK" onClick="Calcola()">
</form>
</b></center>


How to get graphs in JavaScript: click here and here  (see here).


For the teacher, graphs (and calculations) with R (see here):

source("http://macosa.dima.unige.it/r.R")            # if you haven't loaded it yet
f1=function(x) 0*x; f2=function(x) f1(2000)+10/100*(x-2000)
f3=function(x) f2(4000)+20/100*(x-4000); f4=function(x) f3(5500)+35/100*(x-5500)
f=function(x) ifelse(x<=2000,f1(x),ifelse(x<=4000,f2(x),ifelse(x<=5500,f3(x),f4(x))))
g1=function(x) 0*x; g2=function(x) g1(2000)+15/100*(x-2000)
g=function(x) ifelse(x<=2000,g1(x),g2(x))
f(7000); g(7000)
# 1025     750
# Graphs:
BF=3.5; HF=2.8; Plane(0,7000,0,1100)
graph2(f,0,7000, "brown")
x=c(0,2000,4000,5500); POINT(x,f(x),"seagreen")
text(2500,150,"10%",font=2,cex=0.9); text(4500,450,"20%",font=2,cex=0.9); text(5500,750,"35%",font=2,cex=0.9)
abovex("fasce di reddito annuo (D)"); abovey("imposte annue (D)")
BF=3.5; HF=2.8; Plane(0,7000,0,1100)
graph2(g,0,7000, "brown")
x=c(0,2000); POINT(x,g(x),"seagreen")
text(3500,350,"15%",font=2,cex=0.9)
abovex("fasce di reddito annuo (D)"); abovey("imposte annue (D)")

The graphs with Desmos: