Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In the Barrel Simulation, water enters a barrel due to rain. The barrel has capa

ID: 3564528 • Letter: I

Question

In the Barrel Simulation, water enters a barrel due to rain. The barrel has capacity 10000 cups and is initially empty. There is an open hole in the middle of the barrel (i.e. at half the height of the barrel.) Water enters the barrel at a rate of 50 cups per minute.
When the water level reachs that height, it pours out the hole at a rate of 25 cups per minute. What statement must we put inside the doby of the Time Loop so that the hole's effect will be included?

IF (BARREL < 5000) BARREL = 5000 ; ELSE BARREL = BARREL + 25;

IF (BARREL < 5000) BARREL = 5000 ; ELSE BARREL = BARREL + 25;

BARREL = BARREL - 25 ;

BARREL = BARREL + 25 ;

;;    /*put a cork in the hole*/   /* Roll out the barrel. We

a.

IF (BARREL < 5000) BARREL = 5000 ; ELSE BARREL = BARREL + 25;

b.

IF (BARREL < 5000) BARREL = 5000 ; ELSE BARREL = BARREL + 25;

c.

BARREL = BARREL - 25 ;

d.

BARREL = BARREL + 25 ;

e.

;;    /*put a cork in the hole*/   /* Roll out the barrel. We

Explanation / Answer

Since the hole is located at half the height of the barrel, the level in the barrel increases at the rate of 50 cups per minute. The capacity reaches 5000 cups (as the total capacity is 10000).

After the water level reaches half the height; water level increases at the rate of 25 cups per minute. (Since water in the barrel increase at the rate of 50 and leaves from the hole at the rate of 25. Net increase is 50-25 = 25 only.)

Therefore, the correct option is f. IF (BARREL > 5000) BARREL = BARREL + 25;

In the body of the time loop include the statement IF (BARREL > 5000) BARREL = BARREL + 25; to include the hole effect.

Note:

The statement to be included also depends on other computations also. Observe the following code for the differences.

FOR(TIME = 0; TIME <10000; TIME++)

            IF (BARREL > 5000)

BARREL = BARREL + 25;

            ELSE

BARREL = BARREL + 50;

In this case, the correct option will be f. IF (BARREL > 5000) BARREL = BARREL + 25;

In the other case,

FOR(TIME = 0; TIME <10000; TIME++)

BARREL = BARREL + 25;

            IF (BARREL > 5000)

BARREL = BARREL - 25;

In this case, the correct option will be h. IF (BARREL > 5000) BARREL = BARREL - 25;

So based on the remaining statements, decide the correct option.