<?xml version="1.0"?>
<flowgorithm fileversion="3.0">
    <attributes>
        <attribute name="name" value=""/>
        <attribute name="authors" value="burrin"/>
        <attribute name="about" value=""/>
        <attribute name="saved" value="2023-11-05 06:46:32 PM"/>
        <attribute name="created" value="YnVycmluO0RFU0tUT1AtNzQ5RDJJRjsyMDIzLTExLTA1OzA1OjIyOjA0IFBNOzI5Mzc="/>
        <attribute name="edited" value="YnVycmluO0RFU0tUT1AtNzQ5RDJJRjsyMDIzLTExLTA1OzA2OjQ2OjMyIFBNOzE4OzMxMDk="/>
    </attributes>
    <function name="Main" type="None" variable="">
        <parameters/>
        <body>
            <comment text="Flowgorithm for an ATM - Input a value divisible by 10 and then issue the least number of notes for this request"/>
            <comment text="Declare array to store refund counts"/>
            <declare name="refund" type="Integer" array="True" size="6"/>
            <comment text="Set a total to 0 for calculation"/>
            <declare name="total" type="Integer" array="False" size=""/>
            <assign variable="total" expression="0"/>
            <comment text="Declare an array with each note value in"/>
            <declare name="Notes" type="Integer" array="True" size="6"/>
            <assign variable="Notes[0]" expression="5000"/>
            <assign variable="Notes[1]" expression="1000"/>
            <assign variable="Notes[2]" expression="500"/>
            <assign variable="Notes[3]" expression="100"/>
            <assign variable="Notes[4]" expression="50"/>
            <assign variable="Notes[5]" expression="10"/>
            <declare name="request" type="Integer" array="False" size=""/>
            <comment text="request the amount required"/>
            <output expression="&quot;How much do you want?&quot;" newline="True"/>
            <breakpoint expression="" always="True"/>
            <input variable="request"/>
            <comment text="make sure the ammount is divisible by 10"/>
            <while expression="request MOD 10 != 0">
                <output expression="&quot;Invalid amount&quot;" newline="True"/>
                <input variable="request"/>
            </while>
            <comment text="Work out best notes to give"/>
            <comment text="set the total to be the requested ammount"/>
            <assign variable="total" expression="request"/>
            <declare name="counter" type="Integer" array="False" size=""/>
            <assign variable="counter" expression="0"/>
            <while expression="total &gt;0">
                <comment text="go through each note"/>
                <for variable="counter" start="0" end="size(Notes)-1" direction="inc" step="1">
                    <comment text="increment the note counter in refund for note"/>
                    <assign variable="refund[counter]" expression="0"/>
                    <while expression="Notes[counter] &lt;=total">
                        <assign variable="total" expression="total - Notes[counter]"/>
                        <assign variable="refund[counter]" expression="refund[counter]+1"/>
                    </while>
                    <comment text="move to next note"/>
                </for>
            </while>
            <comment text="print notes required"/>
            <output expression="&quot;issuing &#163;&quot;&amp;request" newline="True"/>
            <for variable="counter" start="0" end="size(refund)-1" direction="inc" step="1">
                <if expression="refund[counter] &gt;0">
                    <then>
                        <output expression="refund[counter] &amp; &quot; X  &#163;&quot;&amp;Notes[counter]" newline="True"/>
                    </then>
                    <else/>
                </if>
            </for>
        </body>
    </function>
</flowgorithm>
