wap in java to enter 3 sides of a triangle and find its area using herons formula
Answers
Answered by
7
Answer:
import java.util.*;
public class Triangle2
{
public static void main(String args[ ])
{
Scanner in=new Scanner(System.in);
int a,b,c;
double s=0.0,ar=0.0;
System.out.println("Enter the three sides of the triangle");
a=in.nextInt();
b=in.nextInt();
c=in.nextInt();
if(a+b>c&&b+c>a&&c+a>b)
{
s=(a+b+c)/2.0;
ar=Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.println("The area of triangle="+ar);
}
else
System.out.println("Invalid input Triangle not possible");
}
}
See the attachment for better understanding.
Output is also given check.
Mark as brainliest if the answer is right.
Attachments:
Similar questions
English,
2 months ago
Physics,
2 months ago
Hindi,
2 months ago
Math,
4 months ago
Accountancy,
10 months ago