Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

***Write a Java class that does the following: Prompts the user to input the two

ID: 3641364 • Letter: #

Question

***Write a Java class that does the following:
Prompts the user to input the two measurements which are required to define a Square Pyramid, length, height, we shall assume that these measurements are being given in meters.
Calculate the edge perimeter of the Square Pyramid defined by the given dimensions.

Hints:

1.The Base of the Pyramid is a (length X length) Square.
2.Each of the other four faces is an Isosceles Triangle.
3.Do not confuse the height of each of the Isosceles Triangles with the given height of the Square Pyramid.
4.The height of each of the Isosceles Triangles is given by:
sqrt(pow(height, 2) + pow(length/2, 2));
You should verify that you could have derived this yourself.
5.You will need to use Pythagoras' theorem again to compute the (common) unknown side length of the Isosceles Triangles.
*** Displays this perimeter in some reasonable report format.

Explanation / Answer

import java.util.Scanner; public class SquarePyramid { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter the length of your square pyramid: "); double length = in.nextDouble(); System.out.print("Enter the height of your square pyramid: "); double height = in.nextDouble(); double perimeter = (4 * length) + 4 * (Math.sqrt(Math.pow(Math.sqrt(Math.pow(height, 2) + Math.pow(length/2, 2)), 2) + Math.pow(length/2, 2))); System.out.println("The edge perimeter of the square pyramid is: " + perimeter); } }