A pharmaceutical manufacturer is writing a control system for an automated packaging line. The iterative algorithm below is used to calculate how many standard glass vials are required to package a batch of liquid medication of a given volume in millilitres.
constant LIQUID_VOL ← 150
constant AIR_GAP ← 10
OUTPUT 'Enter the total volume of the batch in ml'
batchVolume ← USERINPUT
totalVialCapacity ← LIQUID_VOL + AIR_GAP
numberOfVials ← 0
REPEAT
batchVolume ← batchVolume - totalVialCapacity
numberOfVials ← numberOfVials + 1
UNTIL batchVolume ≤ 0
The manufacturer realizes that using a loop is computationally inefficient. They decide to rewrite the algorithm using a combination of the DIV and MOD operators with selection.
DIV calculates integer division, e.g. 17 DIV 5=317 \text{ DIV } 5 = 317 DIV 5=3MOD calculates the remainder after integer division, e.g. 17 MOD 5=217 \text{ MOD } 5 = 217 MOD 5=2Complete this new algorithm by stating the code that should be written in the boxes labelled X, Y, and Z. This new algorithm must calculate the same final result for the variable numberOfVials as the original loop-based algorithm.
constant LIQUID_VOL ← 150
constant AIR_GAP ← 10
OUTPUT 'Enter the total volume of the batch in ml'
batchVolume ← USERINPUT
totalVialCapacity ← LIQUID_VOL + AIR_GAP
numberOfVials ← batchVolume DIV totalVialCapacity
IF [ X ] MOD [ Y ] > 0 THEN
numberOfVials ← [ Z ]
ENDIF