Dispatch capacity case
The dispatch manager at fictional Bramble Dispatch can place one mobile desk. Parallel arrays describe unique site names, demand, capacity and closure status. Estimate unserved demand, remove ineligible sites, apply a positive minimum impact rule and return a deterministic recommendation with its unmet count. The final answer is checked on ties, closed sites, spare capacity and an exact-threshold site.
Bramble Dispatch can send one temporary mobile desk to an open site. Demand alone can't decide the destination because a busy site may already have enough capacity. Work from total demand to unserved demand, then account for eligibility and the minimum impact required for the desk.
You will carry the same method through six analysis stages. Each stage changes what the return value means, so read its contract before reusing an earlier calculation. A site with spare capacity contributes zero unserved requests; its surplus doesn't cancel requests at another site. For the recommendation, use the greatest qualifying unserved demand and an alphabetical tie rule. The final checked answer includes both the site and its unserved count, making the decision evidence explicit rather than returning an unsupported label.
int unmet = Math.max(0, demand - capacity);
boolean eligible = !closed && unmet >= minimum;
// Rank eligible sites before formatting site + ":" + unmet.
Choose one eligible dispatch site using checked capacity evidence.