<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Garamond;
        panose-1:2 2 4 4 3 3 1 1 8 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        margin-bottom:5.95pt;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=EN-AU link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>You are right, it never passes to the second loop. And is the TOTAL for the green and red colors combined or do you need two different totals?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>But perhaps something like this is what you were after:<o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>BEGIN</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>SET TOTALGREEN TO 0</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>SET TOTALRED TO 0</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>SET COUNTER TO 1</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>WHILE COUNTER < 4</span><span lang=EN-US><o:p></o:p></span></p><p style='mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:0cm;margin-left:36.0pt;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>TOTALGREEN = TOTALGREEN + COLOUR [COUNTER] . GREENVALUE</span><span lang=EN-US><o:p></o:p></span></p><p style='mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:0cm;margin-left:36.0pt;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>TOTALRED = TOTALRED + COLOUR [COUNTER] . REDVALUE</span><span lang=EN-US><o:p></o:p></span></p><p style='mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:0cm;margin-left:36.0pt;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>ADD 1 TO COUNTER</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>ENDWHILE</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>PRINT TOTALGREEN, TOTALRED<o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>END<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> sofdev-bounces@edulists.com.au [mailto:sofdev-bounces@edulists.com.au] <b>On Behalf Of </b>Brett Groves<br><b>Sent:</b> Wednesday, 25 May 2011 11:43 AM<br><b>To:</b> Year 12 Software Development Teachers' Mailing List<br><b>Subject:</b> [Year 12 SofDev] Help needed<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi all,<br><br>Wondering if some kind soul who is good with desk checks / pseudo code can help me out here. We are about to commence OC2 (running a week late) and I have given my students some algorithms to evaluate for revision. On one in particular I realised I made an error of logic when evaluatiing it myself and have now confused my self to point of frustration. It's the one below. It has two count loops which it uses to select data in an array but they both have identical conditions. As I am currently reading it values will never be passed to the second loop as the evaluation condition that ends the first loop will also end the second???? Scratches head......sure I'm failing to see obvious! Can anyone help pls<br><br>Brett<o:p></o:p></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><b><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>Question 12:</span></b><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>The following diagram shows the contents of an array of records used for mixing colours.</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>The name of the array is ‘COLOUR’.</span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:7.5pt;font-family:"Garamond","serif"'>The algorithm below is used to calculate colour values, using an array.</span> <o:p></o:p></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>BEGIN</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>SET TOTAL TO 0</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>SET COUNTER TO 1</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>WHILE COUNTER < 4</span><span lang=EN-US><o:p></o:p></span></p><p style='mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:0cm;margin-left:36.0pt;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>TOTAL = TOTAL + COLOUR [COUNTER] . GREENVALUE</span><span lang=EN-US><o:p></o:p></span></p><p style='mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:0cm;margin-left:36.0pt;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>ADD 1 TO COUNTER</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>ENDWHILE</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>WHILE COUNTER < 4</span><span lang=EN-US><o:p></o:p></span></p><p style='mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:0cm;margin-left:36.0pt;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>TOTAL = TOTAL + COLOUR [COUNTER] . REDVALUE</span><span lang=EN-US><o:p></o:p></span></p><p style='mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:0cm;margin-left:36.0pt;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>ADD 1 TO COUNTER</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt;text-indent:36.0pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>ENDWHILE</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>PRINT TOTAL</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>END</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US><o:p> </o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>What will be the output of this algorithm?</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>(A) 10</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>(B) 11</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>(C) 18</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-bottom:0cm;margin-bottom:.0001pt'><span lang=EN-US style='font-size:7.5pt;font-family:"Garamond","serif"'>(D) 25</span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p><b>Important - </b>This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Early Childhood Development.<o:p></o:p></p></div></body></html>