write a program in Java to find the area of triangle
Answers
Here is ur answer:
The area of a triangle can be calulated as (s*(s-a)*(s-b)*(s-c))^(1/2), where s is semi-perimeter of the triangle. s = (a + b + c)/2. .
Time Complexity: O(1).
Sanfoundry Global Education & Learning Series – Java Programs..
Hope its help u
mark on brainlist
Answer:
import java.io.*;
public class areatriangle
{
public static void main(String[] args) throws IOException
{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("Enter the First Side");
int a=Integer.parseInt(br.readLine());
System.out.println("Enter the Second Side");
int b=Integer.parseInt(br.readLine());
System.out.println("Enter the Third Side");
int c=Integer.parseInt(br.readLine());
int s=(a+b+c)/2;
int a1=(s*(s-a)*(s-b)*(s-c));
double area=Math.sqrt(a1);
System.out.println("The area of the triangle is = "+area);
}
}
Answered by M.Mithul Pranav
Hope it helps