<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>8.1.21 (Arith. seq. savings 2)</text>
    </name>
    <questiontext format="moodle_auto_format">
      <text><![CDATA[<p>Alice started a new job and earned £\({@earn1@}\) in her first month. Thereafter, her salary increased by £\({@salincy@}\) per year. Her expenses are £\({@expy1@}\) during the first year and the expenses increase by £\({@expincy@}\) per year. How many years will it take for Alice to save £\({@save@}\) per month? Give your answer to the nearest year.</p>

<p>[[input:ans1]] [[validation:ans1]]</p>]]></text>
    </questiontext>
    <generalfeedback format="moodle_auto_format">
      <text><![CDATA[<p>Begin by turning everything into a monthly timetable. Alice's salary increases by £\({@salincy@}/12 =\) £\({@salincm@}\) per month. Similarly, Alices expenses increase by \({@expincy@}/12\) = £\({@expincm@}\) per month.</p>

<p>Next we can write both the expenses and salary as a monthly sequence:
\[
\begin{align*}
&\mbox{salary}: {@earn1@},{@earn1+salincm@}, {@earn1+salincm*2@}, \dots
\\
&\mbox{savings}: {@expy1@},{@expy1+ expincm@}, {@expy1+ expincm@}, \dots
\end{align*}
\]
We can subtract the second sequence from the first which will give us a sequence of how much Alice saves every month. We have:
\[
{@sav1@},{@sav1+dd@},{@sav1+2*dd@}, \dots.
\]
We notice that this sequence is an arithmetic sequence because each term is increasing by \({@dd@}\) per month. Therefore we can write a formula for the sequence as
\[
u_n = a + (n-1)d = {@sav1@} + {@dd@}(n-1).
\]
To find which month Alice saves £\({@save@}\) we substitute \(u_n = {@save@}\) into the formula above and rearrange to get \(n\). So we have 
\[
{@save@} = {@sav1@} + {@dd@}(n-1) \implies {@save-sav1@}/{@dd@} + 1 = n = {@months@}.
\] 
Thus it takes Alice \({@months@}\) months to save £\({@save@}\) or in years, it takes her \({@months@}/12 \approx {@ta1@}\) years.</p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2020081700</text>
    </stackversion>
    <questionvariables>
      <text>earn1: 1000*(1+rand(20));
salincy: 100*(1+rand(15));
salincm: salincy/12;

expy1: 1000*(1+rand(13));
expincy: 100*(1+rand(9));
expincm: expincy/12;

sav1: earn1 - expy1;
dd: salincm-expincm;

save: 1000*(1+rand(20));
months: (save-sav1)/dd + 1;

ta1:round(months/12);</text>
    </questionvariables>
    <specificfeedback format="html">
      <text>[[feedback:prt1]]</text>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>\({@save@} = {@sav1@} + {@dd@}(n-1) \implies\) {@months@} months \(\implies \){@ta1@} years</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <prtcorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:green;"><i class="fa fa-check"></i></span> Correct answer, well done.]]></text>
    </prtcorrect>
    <prtpartiallycorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:orange;"><i class="fa fa-adjust"></i></span> Your answer is partially correct.]]></text>
    </prtpartiallycorrect>
    <prtincorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:red;"><i class="fa fa-times"></i></span> Incorrect answer.]]></text>
    </prtincorrect>
    <decimals>.</decimals>
    <scientificnotation>*10</scientificnotation>
    <multiplicationsign>dot</multiplicationsign>
    <sqrtsign>1</sqrtsign>
    <complexno>i</complexno>
    <inversetrig>cos-1</inversetrig>
    <logicsymbol>lang</logicsymbol>
    <matrixparens>[</matrixparens>
    <isbroken>0</isbroken>
    <variantsselectionseed/>
    <input>
      <name>ans1</name>
      <type>algebraic</type>
      <tans>ta1</tans>
      <boxsize>15</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>1</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>1</showvalidation>
      <options/>
    </input>
    <prt>
      <name>prt1</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans1</sans>
        <tans>ta1</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>690206607</deployedseed>
    <deployedseed>1307547015</deployedseed>
    <deployedseed>1358981849</deployedseed>
    <deployedseed>1709320815</deployedseed>
    <deployedseed>1024609453</deployedseed>
    <deployedseed>2136703073</deployedseed>
    <deployedseed>806159889</deployedseed>
    <deployedseed>916646663</deployedseed>
    <deployedseed>1263985628</deployedseed>
    <deployedseed>1608477747</deployedseed>
    <deployedseed>2075349720</deployedseed>
    <deployedseed>623549330</deployedseed>
    <deployedseed>1612514373</deployedseed>
    <deployedseed>30829269</deployedseed>
    <deployedseed>2001767677</deployedseed>
    <deployedseed>173755328</deployedseed>
    <deployedseed>1002727601</deployedseed>
    <deployedseed>203993065</deployedseed>
    <deployedseed>2049031175</deployedseed>
    <deployedseed>1493339627</deployedseed>
    <deployedseed>1633300369</deployedseed>
    <deployedseed>2115937626</deployedseed>
    <deployedseed>1747434510</deployedseed>
    <deployedseed>913381066</deployedseed>
    <deployedseed>905673265</deployedseed>
    <deployedseed>2078247292</deployedseed>
    <deployedseed>1566318796</deployedseed>
    <deployedseed>1126553613</deployedseed>
    <deployedseed>1709652926</deployedseed>
    <deployedseed>1218949844</deployedseed>
    <deployedseed>1174615806</deployedseed>
    <deployedseed>610046163</deployedseed>
    <deployedseed>1827268365</deployedseed>
    <deployedseed>1120774527</deployedseed>
    <deployedseed>336524802</deployedseed>
    <deployedseed>258270027</deployedseed>
    <deployedseed>14261253</deployedseed>
    <deployedseed>973696307</deployedseed>
    <deployedseed>1075072160</deployedseed>
    <deployedseed>73297751</deployedseed>
    <deployedseed>363875479</deployedseed>
    <deployedseed>720296718</deployedseed>
    <deployedseed>1565831580</deployedseed>
    <deployedseed>1622731522</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ta1</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-1-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ta1-1</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt1-1-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
