{
  "format": "tokbit",
  "version": 1,
  "name": "The other leg",
  "main": [
    {
      "id": "u1",
      "kind": "declare",
      "name": "c",
      "type": "float"
    },
    {
      "id": "u2",
      "kind": "declare",
      "name": "a",
      "type": "float"
    },
    {
      "id": "u3",
      "kind": "doWhile",
      "body": [
        {
          "id": "u4",
          "kind": "input",
          "target": "c",
          "prompt": "Hypotenuse c:"
        },
        {
          "id": "u5",
          "kind": "if",
          "condition": "c <= 0",
          "then": [
            {
              "id": "u6",
              "kind": "output",
              "values": "\"The size must be greater than 0.\""
            }
          ],
          "else": []
        }
      ],
      "condition": "c <= 0"
    },
    {
      "id": "u7",
      "kind": "doWhile",
      "body": [
        {
          "id": "u8",
          "kind": "input",
          "target": "a",
          "prompt": "Leg a:"
        },
        {
          "id": "u9",
          "kind": "if",
          "condition": "a <= 0 or a >= c",
          "then": [
            {
              "id": "u10",
              "kind": "output",
              "values": "\"The leg must be shorter than the hypotenuse.\""
            }
          ],
          "else": []
        }
      ],
      "condition": "a <= 0 or a >= c",
      "comment": "A leg is always shorter than the hypotenuse."
    },
    {
      "id": "u11",
      "kind": "output",
      "values": "\"Leg b =\", round(sqrt(c ** 2 - a ** 2), 2)",
      "comment": "From c² = a² + b² it follows that b = √(c² − a²)."
    }
  ],
  "functions": [],
  "comment": "Solution to the task “The missing leg”: From the hypotenuse c and the leg a compute the other leg b = √(c² − a²). The hypotenuse must be longer than the leg.",
  "screen": "fit"
}
