In the McDonald farm problem (mentioned elsewhere in this quiz), a swarm of fift
ID: 3564531 • Letter: I
Question
In the McDonald farm problem (mentioned elsewhere in this quiz), a swarm of fifty rats invaded the farm. We initialized RATPOP = 50 ; but the rats started breeding. Which statement causes the rat population to double during every time through the TIME LOOP (ie. put this statement in the body of the time loop)?
RATPOP = RATPOP + 2 ;
RATPOP = RATPOP % 2 ;
RATPOP = RATPOP / 2 ;
RATPOP = RATPOP * 2 ;
RATPOP = RATPOP ;
RATPOP = RATPOP * pow(2,TIME) ;
RATPOP = RATPOP * pow(TIME,2) ;
RATPOP = RATPOP + 1 ;
which one is it?
a.RATPOP = RATPOP + 2 ;
b.RATPOP = RATPOP % 2 ;
c.RATPOP = RATPOP / 2 ;
d.RATPOP = RATPOP * 2 ;
e.RATPOP = RATPOP ;
f.RATPOP = RATPOP * pow(2,TIME) ;
g.RATPOP = RATPOP * pow(TIME,2) ;
h.RATPOP = RATPOP + 1 ;
Explanation / Answer
To double any quantity, multiply the quantity with 2. So, if the rat population is doubled, to get the doubled value multiply RATPOP with 2 (that is RATPOP * 2).
The statement that can be used to double the rat population during every time through the TIME LOOP is d. RATPOP = RATPOP * 2;
The statement to insert in the body of the time loop is d. RATPOP = RATPOP * 2;
Therefore, the correct answer is d. RATPOP = RATPOP * 2;
Get back to me if you need any clarification.