Applied record case: sell from a bounded inventory

This is an original invented practice case, not a reconstruction of either unspecified BITS case study. Model at most five inventory items using Stock(id,name,quantity,cents). Input gives n (0..5), then n rows id name quantity cents; ids are unique in 1..999, names are tokens of 1..11 characters, quantities are 0..20 and prices 0..999 cents. Next comes t (0..8), then t requests id units, with id in 1..999 and units 1..20. A sale succeeds only if the id exists and sufficient stock remains; failure changes no item. Write sell(items,n,id,units) returning a Sale record containing accepted and amount. Use linear search, preserve item order, update the actual array on success, and total revenue in long integer cents. Print OK ID AMOUNT or REJECT ID for each request, then REVENUE TOTAL, then every remaining item as id name quantity. Explain why a successful free item must be distinguished from a rejected sale.


