Report capacity reserve and assign a small reliability label.

capacity-reserve-report A reserve report keeps the arithmetic visible before assigning a status label.

Capacity Reserve Reliability Report

demand
CapacityReserveReliabilityReport.scala
Replay: real traced execution (multi-file project)
object Main {
  def main(args: Array[String]): Unit = {
    val demand = 72
    val capacity = 100
    val reserve = capacity - demand
    var status = "stable"

    if (reserve < 15) {
      status = "watch"
    }
    if (reserve < 8) {
      status = "tight"
    }

    println("demand=" + demand)
    println("reserve=" + reserve)
    println("status=" + status)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val demand = 88
    val capacity = 100
    val reserve = capacity - demand
    var status = "stable"

    if (reserve < 15) {
      status = "watch"
    }
    if (reserve < 8) {
      status = "tight"
    }

    println("demand=" + demand)
    println("reserve=" + reserve)
    println("status=" + status)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val demand = 95
    val capacity = 100
    val reserve = capacity - demand
    var status = "stable"

    if (reserve < 15) {
      status = "watch"
    }
    if (reserve < 8) {
      status = "tight"
    }

    println("demand=" + demand)
    println("reserve=" + reserve)
    println("status=" + status)
  }
}
  1. demand ← 72, capacity ← 100, reserve ← 28, status ← stable

    1object Main {2  def main(args: Array[String]): Unit = {3    val demand→ 72 = 72 //@demand=88, 954    val capacity→ 100 = 1005    val reserve→ 28 = capacity100 - demand726    var status→ stable = "stable"78    if (reserve < 15) {9      status = "watch"10    }11    if (reserve < 8) {12      status = "tight"13    }1415    println("demand=" + demand72)16    println("reserve=" + reserve28)17    println("status=" + statusstable)18  }19}
    outputdemand=72
    reserve=28
    status=stable
  1. demand ← 88, capacity ← 100, reserve ← 12, status ← stable

    1object Main {2  def main(args: Array[String]): Unit = {3    val demand→ 88 = 884    val capacity→ 100 = 1005    val reserve→ 12 = capacity100 - demand886    var status→ stable = "stable"78    if (reserve < 15) {
  2. status ← watch

    8if (reserve12 < 15) {9  status→ watch = "watch"10}11if (reserve < 8) {
  3. println("demand=" + demand)

    15    println("demand=" + demand88)16    println("reserve=" + reserve12)17    println("status=" + statuswatch)18  }19}
    outputdemand=88
    reserve=12
    status=watch
  1. demand ← 95, capacity ← 100, reserve ← 5, status ← stable

    1object Main {2  def main(args: Array[String]): Unit = {3    val demand→ 95 = 954    val capacity→ 100 = 1005    val reserve→ 5 = capacity100 - demand956    var status→ stable = "stable"78    if (reserve < 15) {
  2. status ← watch

    8if (reserve5 < 15) {9  status→ watch = "watch"10}11if (reserve < 8) {
  3. status ← tight

    10}11if (reserve5 < 8) {12  status→ tight = "tight"13}
  4. println("demand=" + demand)

    15    println("demand=" + demand95)16    println("reserve=" + reserve5)17    println("status=" + statustight)18  }19}
    outputdemand=95
    reserve=5
    status=tight