Lessons 26–30 · About 60 min per lesson
Project: farm inventory
Combine input, decisions, loops and functions into a complete program.
Lesson breakdown
- Lesson 26
Define the input format and distinguish delivery and request events.
- Lesson 27
Trace how each event changes the stock and what it prints.
- Lesson 28
Read events one line at a time, implement deliveries and then add requests.
- Lesson 29
Extract the request rule into a function and retest mixed event sequences.
- Lesson 30
Submit runnable code, usage instructions and three input sets with expected output.
Worked example
Start with 4 kg and process REQ 5, ADD 3 and REQ 5. Print only request statuses during processing, then print final stock.
How to solve it
Print Wait, Enough and 2. The first request leaves 4 kg, the delivery raises it to 7, and the last request leaves 2.
Assignment
Finish the inventory program and add a line that prints the total kilograms successfully issued. Include three test inputs of your own.
Check your result
The example ends at stock 2 and total issued 5. Deliveries alone issue 0 kg, and an exact request leaves stock 0.