Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm exam 1 review Sp2006: Tracing Complex Picture Method

Questions, comments, concerns, answers, concerns about answers?
(Back to Midterm Exam 1 Review Sp2006)


Did anyone else find this a royal pain?
I really don't know if all of these are right–check my math... That last one... Bleh.

(a) (255,255,255)
(255,255,255)
No REMOVEDge!

(b) (128,36,100)
(128,64,100)
Loops 28 times, each time green is 128, so add 28 to green.

(c) (200,250,5)
(200,231,5)
(int)(195/10)=19, Loop 19 times, green is never 128, so subtract 19

(d) (5,25,200) Wrong! See below...
(5,128,200)
Grr. Loop 195 times, starting with green value @25. Eventually, green will be 128, then subtract 1, then add 1, and so on.
Question is, does that make it 127 or 128 when the loop stops? Little help?

I'm still really confused on this one. I ran the code on dr.java and added a few lines to print every time the values change. I can tell you that on (d), the value did go through both if statements. It starts out at -195, changes to 195, then to 19. Everything seemed fine until the end when somehow the red and blue values change and the green value isn't close to any answer.

Be confused no more–you're right!
What I (presumptuously and incorrectly) did, was assume that there was an 'else' where there wasn't.
So, I overlooked the second if statement (the one about value being bigger than 150) completely and did the loop 195 times!
You are quite correct, though. It only goes 19 times, like the previous one.
So, the answer should, be, I think, (5,44,200)?
This is why time for discussion is really, really good.
Thanks!
~Student248

I'm confused.. cause it would only go through that one pixel once.. so since it's value was already changed from a negative to a positive, how does it then become 19?? Just because it's another if?? ;P Bleh.
~Jennifer

:) It goes through the entire section under "//loop through all the pixels" once for each pixel, but it goes through all those lines.
So, yep. It does the first if, making -195 to 195, then it hits the second if, and since 195 is greater than 150, it takes the integer part of 195/10, which is 19.
And then executes that for loop with j in it. That whole thing is encapsulated in the brackets of the "//loop through all the pixels" loop, so it all gets performed.
Hope that helps! ~Jim



Link to this Page