Compare current demand with fixed capacity and report remaining reserve.

reserve Reserve is the capacity left after current demand has been accounted for.
capacity status A compact label separates stable, watch, and tight capacity states.

Capacity Reserve Reliability Report

demand
capacity_reserve_reliability_report.cpp
Replay: real traced execution (multi-file project)
#include <iostream>
#include <string>

int main() {
    int demand = 72;
    int capacity = 100;
    int reserve = capacity - demand;
    std::string status = "stable";

    if (reserve < 20) {
        status = "watch";
    }

    if (reserve < 10) {
        status = "tight";
    }

    std::cout << "demand=" << demand << std::endl;
    std::cout << "reserve=" << reserve << std::endl;
    std::cout << "status=" << status << std::endl;
    return 0;
}
#include <iostream>
#include <string>

int main() {
    int demand = 88;
    int capacity = 100;
    int reserve = capacity - demand;
    std::string status = "stable";

    if (reserve < 20) {
        status = "watch";
    }

    if (reserve < 10) {
        status = "tight";
    }

    std::cout << "demand=" << demand << std::endl;
    std::cout << "reserve=" << reserve << std::endl;
    std::cout << "status=" << status << std::endl;
    return 0;
}
#include <iostream>
#include <string>

int main() {
    int demand = 95;
    int capacity = 100;
    int reserve = capacity - demand;
    std::string status = "stable";

    if (reserve < 20) {
        status = "watch";
    }

    if (reserve < 10) {
        status = "tight";
    }

    std::cout << "demand=" << demand << std::endl;
    std::cout << "reserve=" << reserve << std::endl;
    std::cout << "status=" << status << std::endl;
    return 0;
}
  1. demand ← 72, capacity ← 100, reserve ← 28, status ← stable

    4int main() {5    int demand→ 72 = 72; //@demand=88, 956    int capacity→ 100 = 100;7    int reserve→ 28 = capacity100 - demand72;8    std::string status→ stable = "stable";910    if (reserve < 20) {11        status = "watch";12    }1314    if (reserve < 10) {15        status = "tight";16    }1718    std::cout << "demand=" << demand72 << std::endl;19    std::cout << "reserve=" << reserve28 << std::endl;20    std::cout << "status=" << statusstable << std::endl;21    return 0;22}
    outputdemand=72
    reserve=28
    status=stable
  1. demand ← 88, capacity ← 100, reserve ← 12, status ← stable

    4int main() {5    int demand→ 88 = 88;6    int capacity→ 100 = 100;7    int reserve→ 12 = capacity100 - demand88;8    std::string status→ stable = "stable";
  2. status ← watch

    10if (reserve12 < 20) {11    status→ watch = "watch";12}
  3. std::cout << "demand=" << demand << std::endl;

    18    std::cout << "demand=" << demand88 << std::endl;19    std::cout << "reserve=" << reserve12 << std::endl;20    std::cout << "status=" << statuswatch << std::endl;21    return 0;22}
    outputdemand=88
    reserve=12
    status=watch
  1. demand ← 95, capacity ← 100, reserve ← 5, status ← stable

    4int main() {5    int demand→ 95 = 95;6    int capacity→ 100 = 100;7    int reserve→ 5 = capacity100 - demand95;8    std::string status→ stable = "stable";
  2. status ← watch

    10if (reserve5 < 20) {11    status→ watch = "watch";12}
  3. status ← tight

    14if (reserve5 < 10) {15    status→ tight = "tight";16}
  4. std::cout << "demand=" << demand << std::endl;

    18    std::cout << "demand=" << demand95 << std::endl;19    std::cout << "reserve=" << reserve5 << std::endl;20    std::cout << "status=" << statustight << std::endl;21    return 0;22}
    outputdemand=95
    reserve=5
    status=tight