ProdanTenev

housePainting

Feb 8th, 2022 (edited)
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.19 KB | None | 0 0
  1. function housePainting(input) {
  2.     // Разхода на зелената боя е 1 литър за 3.4 м2, а на червената – 1 литър за 4.3 м2
  3.     let greenPaintConsumption = 3.4;
  4.     let redPaintConsumption = 4.3;
  5.     let windowArea = 1.5 * 1.5;
  6.     let doorArea = 1.2 * 2;
  7.     let heightHouse = Number(input[0]);
  8.     let rectangleWall = Number(input[1]);
  9.     let heightTriangleRoofWall = Number(input[2]);
  10.     // Walls
  11.     let sideWall = heightHouse * rectangleWall;
  12.     let areaSideWalls = (2 * sideWall) - 2 * windowArea;
  13.     let backSideWall = heightHouse * heightHouse;
  14.     let frontSideWall = backSideWall - doorArea;
  15.     let frontAndBackWalls = frontSideWall + backSideWall;
  16.     let totalWallsArea = frontAndBackWalls + areaSideWalls;
  17.     let neededGreenPaint = totalWallsArea / greenPaintConsumption;
  18.     // Roofs
  19.     let roofRectangles = (heightHouse * rectangleWall) * 2;
  20.     let roofTriangles = (heightHouse * heightTriangleRoofWall / 2) * 2;
  21.     let totalRoofArea = roofRectangles + roofTriangles;
  22.     let neededRedPaint = totalRoofArea / redPaintConsumption;
  23.     console.log(neededGreenPaint.toFixed(2));
  24.     console.log(neededRedPaint.toFixed(2));
  25. }
Add Comment
Please, Sign In to add comment