Write a program in java to accept the side of an equilateral triangle and calculate its area
Answers
Answered by
6
import java.util.*;
public class Area
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int s,a;
System.out.println("Enter the side")
s=in.nextInt();
a= Math.sqrt(3*s*s/4);
System.out.println("The area is"+a);
}
}
Answered by
7
import java.util.Scanner;
class AreaOfEquilateralTriangle
{
public static void main(String args[])
{
Scanner s= new Scanner(System.in);
System.out.println("Enter the side of the Triangle:");
double a= s.nextDouble();
double area=(Math.sqrt(3)/4)*(a*a);
System.out.println("Area of Triangle is: " + area);
}
}
Output :
1
2
3
Enter the side of the Triangle:
5
Area of Triangle is:10.82
Similar questions