Reactor Cooling Diagnostics – Task 2
Over the past few days, your cooling monitor has proven useful. The crew now checks the summary report each shift to confirm that the reactor is operating safely. But a new problem has emerged.
During the night shift, efficiency dropped below acceptable limits for several minutes before recovering. The summary report showed an average efficiency of 40%, which seemed fine, but it concealed a dangerous dip that nearly triggered an emergency shutdown. The crew wants to know not just the average, but whether any individual measurement fell into the danger zone.
Station policy defines cooling efficiency below 35% as critical. If efficiency drops this low, even briefly, the reactor control team must be notified immediately so they can investigate the cause. Right now, there is no easy way to detect this from the log without reading every line manually.
The log file format has not changed. Each line still records a timestamp, the subsystem name, and the measured efficiency:
08:12 ReactorCooling: efficiency=42%
08:13 ReactorCooling: efficiency=31%
08:14 ReactorCooling: efficiency=41%
08:15 ReactorCooling: efficiency=29%
08:16 ReactorCooling: efficiency=44%
08:17 ReactorCooling: efficiency=40%
Your program should now read the same cooling_log.txt file and process every measurement, but in addition to reporting the total count, average efficiency, and highest efficiency, it must also count how many measurements fell below the 35% critical threshold. This count will tell the crew whether the cooling system experienced dangerous conditions, even if the average looks acceptable.
For the example data shown above, a correct program would produce output similar to:
Measurements: 6
Average efficiency: 37%
Highest efficiency: 44%
Critical readings (below 35%): 2
Your program should accomplish this using only the tools introduced so far: reading from a file, parsing each line, and using variables to accumulate totals. Do not store all values in a list or array. Process each measurement as you read it, updating your running totals as you go.
The crew is beginning to trust your reports. Soon, they will ask for more detailed breakdowns as other systems begin logging similar data in different formats.