Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function housePainting(input) {
- // Разхода на зелената боя е 1 литър за 3.4 м2, а на червената – 1 литър за 4.3 м2
- let greenPaintConsumption = 3.4;
- let redPaintConsumption = 4.3;
- let windowArea = 1.5 * 1.5;
- let doorArea = 1.2 * 2;
- let heightHouse = Number(input[0]);
- let rectangleWall = Number(input[1]);
- let heightTriangleRoofWall = Number(input[2]);
- // Walls
- let sideWall = heightHouse * rectangleWall;
- let areaSideWalls = (2 * sideWall) - 2 * windowArea;
- let backSideWall = heightHouse * heightHouse;
- let frontSideWall = backSideWall - doorArea;
- let frontAndBackWalls = frontSideWall + backSideWall;
- let totalWallsArea = frontAndBackWalls + areaSideWalls;
- let neededGreenPaint = totalWallsArea / greenPaintConsumption;
- // Roofs
- let roofRectangles = (heightHouse * rectangleWall) * 2;
- let roofTriangles = (heightHouse * heightTriangleRoofWall / 2) * 2;
- let totalRoofArea = roofRectangles + roofTriangles;
- let neededRedPaint = totalRoofArea / redPaintConsumption;
- console.log(neededGreenPaint.toFixed(2));
- console.log(neededRedPaint.toFixed(2));
- }
Add Comment
Please, Sign In to add comment