29 lines
1.1 KiB
HTML
29 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Geometry Calculator</title>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
"use strict";
|
|
|
|
// get the length of side A and B
|
|
const sideA = prompt("Enter length of A: ");
|
|
const sideB = prompt ("Enter length of B:");
|
|
// calculate the perimeter of the rectangle
|
|
const perimeterOfRectangle = 2 * (parseInt(sideA) + parseInt(sideB));
|
|
console.log("Perimeter: " + perimeterOfRectangle);
|
|
// calculate the area of the rectangle
|
|
const areaOfRectangle = parseInt(sideA) * parseInt(sideB);
|
|
console.log("Area: " + areaOfRectangle);
|
|
// get the hypotenuse of the right triangle
|
|
// c = sqrt(a^2 + b^2)
|
|
const hypo = Math.sqrt((Math.pow(parseInt(sideA), 2)) + (Math.pow(parseInt(sideB), 2)));
|
|
console.log("Hypotenuse: " + hypo.toFixed(4));
|
|
// pythagorean theorem : c = sqrt(a^2 + b^2)
|
|
|
|
// display the results to the user
|
|
//completed in steps above
|
|
</script>
|
|
</body>
|
|
</html> |