A school wants to automate watering in its greenhouse using a simple computer program.
You have been asked to write a program to help monitor soil moisture and control when the irrigation system should switch on.
Write a program that:
Asks the user to enter the current soil moisture level as a percentage (0–100).
Validates the input and forces the user to re-enter the value if it is outside the range.
The irrigation system follows these rules:
Soil Moisture (%)
Action
Below 30%
Irrigation turns ON
Between 30%–60%
Irrigation stays OFF
Above 60%
Display “Soil too wet – check drainage.”
Your program must output the correct action based on the validated input.
Extend your program to:
Ask the user how many readings they want to enter for the day.
For each reading:
Enter and validate a moisture percentage
Count how many times the irrigation would have turned ON
At the end of the day, output:
The average moisture level
The number of irrigation activations
The highest and lowest moisture readings
Add the following optional extension:
Store all readings in a list/array.
Export them to a text file called greenhouse_log.txt, each reading on a new line.
Append the day’s average moisture at the end of the file.