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

An employee charged with topping up an oil reservoir is given the following inst

ID: 3837140 • Letter: A

Question

An employee charged with topping up an oil reservoir is given the following instructions:

while the reservoir contains less than 20 litres do
if the reservoir contains less than 16 litres then
   add a 5 litre can of oil to the reservoir
else
   add a 1 litre can of oil to the reservoir
endif
endwhile

a) How much oil will the reservoir wind up containing if it initially contains 14.5 litres of oil?
b) How much oil will the reservoir wind up containing if it initially contains 20.1 litres of oil?

Explanation / Answer

(a) initially contains 14.5 litres of oil
While condition True
else --> 15.5
else --> 16.5
if   --> 21.5

end while loop

reservoir wind up containing : 21.5 Liters

(b) initially contains 20.1 litres of oil

while loop condition False : end while loop
reservoir wind up containing : 20.1 Liters

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote