Write a java program to calculate area of a Tetrahedron?

To calculate the surface area of a Tetrahedron, we need to use the following formula:

Surface Area = √3 × a^2

Where a is the length of one of the edges of the tetrahedron.

To write a Java program to calculate the surface area of a tetrahedron, we can use the following code: 

 

import java.util.Scanner;

public class TetrahedronArea {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter the length of one of the edges of the tetrahedron: ");
        double a = input.nextDouble();
        double surfaceArea = Math.sqrt(3) * a * a;
        System.out.println("The surface area of the tetrahedron is: " + surfaceArea);
    }
}

In this code, we first import the Scanner class to allow the user to input the length of one of the edges of the tetrahedron. We then prompt the user to enter the length and store it in the variable "a". We calculate the surface area using the formula above and store it in the variable "surfaceArea". Finally, we print out the surface area of the tetrahedron to the console using the System.out.println() method.

Submit Your Programming Assignment Details