!readproc $authordir/afronding.$taal
bewerking=bewerking6.proc
n=$teller
!if $taal=nl
    nivo_title=Tabel en exponenti&euml;le groei
    somtekst=Vul de tabel in aan de hand van deze formule<br><small><em>$AFRONDING</em></small><br>
    VAR1=x,tijd,minuten,dagen,maanden,seconden
    VAR2=y,hoeveelheid,afstand,opbrengst,omzet,hoogte
!else
    nivo_title=Table and a function of growth
    somtekst=Fill in the table according to the given function<br><small><em>$AFRONDING</em></small><br>
    VAR1=x,time,minutes,days,month,seconds
    VAR2=y,amount,distance,revenue,turnover,height
!endif
!if $wims_user=supervisor
    readonly=$empty
!else
    resdonly=readonly
!endif        
r=!randitem 1,2,3,4,5,6
TIJD=!item $r of $VAR1
H=!item $r of $VAR2

tabel1=$empty
tabel2=$empty    
tabel3=$empty
!if $graad=0    
    R=$teller
!else
    R=$graad
!endif

!if $aantal_vragen < 4
    aantal_vragen=4
!endif

keuze=!randitem 1,0
getal=!randint 5,200
p=!randint 80,220

!if $p=100
    p=120
!endif
p=$[$p/100]

!if $R<4
    !if $R = 1
	!for s=1 to $aantal_vragen
	    getal$s=$[$s-1]
	    tabel1=!append line <th>$(getal$s)</th> to $tabel1
    	    pari_vraag=!append line round($afrondingsfactor*$getal*$p^($(getal$s)))/(1.0*$afrondingsfactor) to $pari_vraag
	!next s	
    !endif
    !if $R = 2 
	r=!randitem 2,3,4
	!for s=1 to $aantal_vragen
	    getal$s=$[$r*$s-$r]
	    tabel1=!append line <th>$(getal$s)</th> to $tabel1
	    pari_vraag=!append line round($afrondingsfactor*$getal*$p^($(getal$s)))/(1.0*$afrondingsfactor) to $pari_vraag
	!next s	
    !endif
    !if $R = 3
	r=!randitem 1,2,3,4
	q=!randitem -8,-7,-6,-5,-4,-3,-2
	!for s=1 to $aantal_vragen
	    getal$s=$[$q+$r*($s-1)]
	    tabel1=!append line <th>$(getal$s)</th> to $tabel1
	    pari_vraag=!append line round($afrondingsfactor*$getal*$p^($(getal$s)))/(1.0*$afrondingsfactor) to $pari_vraag
	!next s	
    !endif
    pari_antwoord=!exec pari $pari_vraag
    !for s=1 to $aantal_vragen
	GOED$s=!line $s of $pari_antwoord
	tabel2=!append line <th><input size="8" name="ant$s"></th> to $tabel2
	tabel3=!append line <th><input size="8" name="ant$s" value="$(GOED$s)" $readonly></th> to $tabel3
    !next s	   
    formule$n= \begin{bf} $H \end{bf} \,\, =\,\, $getal \cdot $p^{^{\begin{bf} $TIJD \end{bf} } }
    opgave$n=<table border="1" width=50% cellpadding="8"><th>$TIJD</th>$tabel1<tr><th>$H</th>$tabel2</table>
    antwoord$n=<table border="1" width=50% cellpadding="8"><th>$TIJD</th>$tabel1<tr><th>$H</th>$tabel3</table>
 !exit
!endif

!if $R >3
    t=!randitem 1/2,1/3,1/4,3/4,2/3,5/3,7/4,7/3,8/5,9/4,3/8,5/8,7/8,8/9
    !for s=1 to $aantal_vragen
	G=$[$s*$t]
	pari_vraag=!append line $s*$t to $pari_vraag
	pari_vraag=!append line round($afrondingsfactor*$getal*$p^($G))/(1.0*$afrondingsfactor) to $pari_vraag	
    !next s	
    pari_antwoord=!exec pari $pari_vraag
    f=1   
    !for s=1 to $aantal_vragen
	getal$s=!line $f of $pari_antwoord
	GOED$s=!line $[$f+1] of $pari_antwoord
	f=$[$f+2]  
	tabel1=!append line <th>$(getal$s)</th> to $tabel1
	tabel2=!append line <th><input size="8" name="ant$s"></th> to $tabel2
	tabel3=!append line <th><input size="8" name="ant$s" value="$(GOED$s) $readonly"></th> to $tabel3
    !next s	   
    formule$n= \begin{bf} $H \end{bf} \,\, =\,\, $getal \cdot $p^{^{\begin{bf} $TIJD \end{bf} } }
    opgave$n=<table border="1" width=50% cellpadding="8"><th>$TIJD</th>$tabel1<tr><th>$H</th>$tabel2</table>
    antwoord$n=<table border="1" width=50% cellpadding="8"><th>$TIJD</th>$tabel1<tr><th>$H</th>$tabel3</table>
!endif