[Year 12 SofDev] Help needed

John Schwartz jschwartz at parade.vic.edu.au
Wed May 25 15:29:22 EST 2011


Surely the total depends on the values of redvalue and greenvalue which
aren't given. As it stands, only greenvalue would be used as you would
skip the second loop.

 

John

 

From: Brett Groves [mailto:groves.brett.g at edumail.vic.gov.au] 
Sent: Wednesday, 25 May 2011 11:43 AM
To: Year 12 Software Development Teachers' Mailing List
Subject: [Year 12 SofDev] Help needed

 

Hi all,

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

Brett

Question 12:

The following diagram shows the contents of an array of records used for
mixing colours.

The name of the array is 'COLOUR'.

The algorithm below is used to calculate colour values, using an array. 

BEGIN

SET TOTAL TO 0

SET COUNTER TO 1

WHILE COUNTER < 4

TOTAL = TOTAL + COLOUR [COUNTER] . GREENVALUE

ADD 1 TO COUNTER

ENDWHILE

WHILE COUNTER < 4

TOTAL = TOTAL + COLOUR [COUNTER] . REDVALUE

ADD 1 TO COUNTER

ENDWHILE

PRINT TOTAL

END

 

What will be the output of this algorithm?

(A) 10

(B) 11

(C) 18

(D) 25

 

Important - 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.


John Schwartz
Parade College
1436 Plenty Road
Bundoora, Victoria, 3083
Phone: 03 9468 3300
Fax: 03 9467 3937
e-mail: jschwartz at parade.vic.edu.au | web: www.parade.vic.edu.au


This e-mail and any attachments may be confidential. You must not disclose or use the information in this e-mail if you are not the intended recipient. If you have received this e-mail in error, please notify Parade College on (03) 9468 3300 immediately and delete the e-mail and all copies. Parade College does not guarantee that this e-mail is virus or error free. The attached files are provided and may only be used on the basis that the user assumes all responsibility for any loss, damage or consequence resulting directly or indirectly from the use of the attached files, whether caused by the negligence of the sender or not. Any views expressed in this e-mail are the views of the individual sending the message, and do not necessarily reflect the views held by Parade College.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20110525/d68167e7/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 8273 bytes
Desc: not available
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20110525/d68167e7/attachment-0001.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 81508 bytes
Desc: not available
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20110525/d68167e7/attachment-0001.jpe 


More information about the sofdev mailing list