write a java program to input three sides of a triangle, evaluate and print the area of triangle using the area is= √s(s-a)(s-b)(s-c) where s=a+b+c/2 and a,b,c are the three sides
Answers
Answer:
// Java Program to find Area of Triangle and Perimeter of a Triangle
package Area;
import java.util.Scanner;
public class AreaOfTriangle {
private static Scanner sc;
public static void main(String[] args) {
double a, b, c, Perimeter, s, Area;
sc = new Scanner(System.in);
System.out.println("\n Please Enter Three sides of triangle: ");
a = sc.nextDouble();
b = sc.nextDouble();
c = sc.nextDouble();
Perimeter = a + b + c;
s = (a + b + c)/2; // Perimeter/2
Area = Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.format("\n The Perimeter of Traiangle = %.2f\n", Perimeter);
System.out.format("\n The Semi Perimeter of Traiangle = %.2f\n",s);
System.out.format("\n The Area of triangle = %.2f\n",Area);
}
}
I hope this answer can help you all ,,,^_^