{
  "format": "tokbit",
  "version": 1,
  "name": "Triangle",
  "main": [
    {
      "id": "u1",
      "kind": "declare",
      "name": "a",
      "type": "float"
    },
    {
      "id": "u2",
      "kind": "declare",
      "name": "b",
      "type": "float"
    },
    {
      "id": "u3",
      "kind": "doWhile",
      "body": [
        {
          "id": "u4",
          "kind": "input",
          "target": "a",
          "prompt": "Leg a:"
        },
        {
          "id": "u5",
          "kind": "if",
          "condition": "a <= 0",
          "then": [
            {
              "id": "u6",
              "kind": "output",
              "values": "\"The size must be greater than 0.\""
            }
          ],
          "else": []
        }
      ],
      "condition": "a <= 0",
      "comment": "Asks again until the size is positive."
    },
    {
      "id": "u7",
      "kind": "doWhile",
      "body": [
        {
          "id": "u8",
          "kind": "input",
          "target": "b",
          "prompt": "Leg b:"
        },
        {
          "id": "u9",
          "kind": "if",
          "condition": "b <= 0",
          "then": [
            {
              "id": "u10",
              "kind": "output",
              "values": "\"The size must be greater than 0.\""
            }
          ],
          "else": []
        }
      ],
      "condition": "b <= 0"
    },
    {
      "id": "u11",
      "kind": "declare",
      "name": "c",
      "type": "float",
      "init": "sqrt(a ** 2 + b ** 2)",
      "comment": "Pythagorean theorem: c² = a² + b². hypot(a, b) gives the same."
    },
    {
      "id": "u12",
      "kind": "output",
      "values": "\"Hypotenuse c =\", round(c, 2)"
    },
    {
      "id": "u13",
      "kind": "output",
      "values": "\"Perimeter:\", round(a + b + c, 2)"
    },
    {
      "id": "u14",
      "kind": "output",
      "values": "\"Area:\", round(a * b / 2, 2)"
    }
  ],
  "functions": [],
  "comment": "Solution to the task “Perimeter and area of the triangle”: Also print the perimeter p = a + b + c and the area A = a · b / 2 of the right triangle.",
  "screen": "fit"
}
