diff --git a/js/formulas.js b/js/formulas.js index 2435d53..7c31ddf 100644 --- a/js/formulas.js +++ b/js/formulas.js @@ -1,80 +1,96 @@ // Basic math formulaas function addition(num1, num2){ - return -1; + return num1 + num2; } +//let sum = addition(23, 47); +//console.log (sum); function subtraction(num1, num2){ - return -1; + return num1 - num2; } +//let sum = subtraction(23, 47); +//console.log (sum); function multiplication(num1, num2){ - return -1; + return num1 * num2; } +//let sum = multiplication(23, 47); +//console.log (sum); function division(num1, num2){ - return -1; + return num1 / num2; } +//let sum = division(23, 47); +//console.log (sum); + + // Area formulaas function areaSquare(side){ - return -1; + return side * side; } +//let side = areaSquare(2); +//console.log (side); + function areaRectangle(length, width){ - return -1; + return length * width; } + // let area = areaRectangle(25, 75); + //console.log (area); + function areaParallelogram(base, height){ - return -1; + return base * height; } function areaTriangle(base, height){ - return -1; + return (base * height) / 2; } function Circle(radius){ - return -1; + return Math.pow(radius, 2) * Math.PI; } function Sphere(radius){ - return -1; + return 4 * Math.PI * Math.pow(radius, 2); } // Surface Area formulas function surfaceAreaCube(side){ - return -1; + return 6 * Math.pow(side, 2); } function surfaceAreaCylinder(radius, height){ - return -1; + return 2 * Math.PI * radius * height; } // Perimeter formulas function perimeterSquare(side){ - return -1; + return 4 * side; } function perimeterRectangle(length, height){ - return -1; + return (2 * length) + (2 * height); } function perimeterTriangle(side1, side2, side3){ - return -1; + return side1 + side2 + side3; } function perimeterCircle(diameter){ - return -1; + return Math.PI * diameter; } // Volume formulas function volumeCube(side){ - return -1; + return Math.pow(side, 3); } function volumeRectangular(length, width, height){ - return -1; + return length * width * height; } function volumeCylinder(radius, height){ - return -1; + return Math.PI * Math.pow(radius, 2) * height; }