A laboratory program calls an energy-summary module once per test batch. Its interface promises to return the total energy for the current batch, in joules, independently of earlier batches.
Two implementations use the same inputs and output units:
The retained total is hidden state: stored information from earlier calls that is not supplied as a current input. Both implementations run in separate, newly started programs. Each receives the three batches below in the listed order.
Complete the table with the returned energies. Enter exact integers; all outputs are in joules.
Unlock full course notes by signing up
Following quantities through module handoffs
A heater-test program has three modules. Its input adapter converts elapsed time from minutes to seconds. Its calculation module accepts constant power in watts and elapsed time in seconds, returning E=PΔtE=P\Delta tE=PΔt in joules. Its reporting module divides the energy in joules by 1000 to display kilojoules.
The recorded power is 135 W135\ \text{W}135 W and the elapsed time is 2.50 min2.50\ \text{min}2.50 min. What energy should the reporting module display? Give your answer in kilojoules, to two decimal places.
Finding a failure between tested modules
A mechanical-work program uses an input adapter, a calculation module, and a reporting module. The calculation contract is W=FdW=FdW=Fd, with force in newtons, displacement in metres, and work returned in joules. Reporting converts joules to kilojoules.
After support for a new recorder is added, these tests are observed:
Which response best uses this evidence while preserving the documented module contracts?
Preserving numerical meaning during replacement
An energy module accepts one or more intervals, each containing a finite nonnegative power PiP_iPi in watts and a finite positive duration Δti\Delta t_iΔti in seconds. Its public contract returns total energy in joules:
A replacement keeps the same inputs and output type but calculates the ordinary arithmetic mean of the powers and multiplies it by the total duration. It passes tests with one interval and tests with equal interval durations.
Reusing results after overlapping input changes
An engineering analysis program separates its work into three modules:
The geometry module takes geometry data and returns section properties. Each call takes 0.8 s.
The stiffness module takes section properties and a material's elastic modulus, a measure of its resistance to elastic deformation. Each call takes 1.5 s.