Kevin321888999

AreaofaTriangle

Sep 30th, 2022
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Banner();
  5.         Scanner SC=new Scanner(System.in);
  6.         System.out.println("Enter the length of the three sides of a triangle: ");
  7.         double a= SC.nextDouble();
  8.         double b= SC.nextDouble();
  9.         double c= SC.nextDouble();
  10.         double s=a+b+c;
  11.         System.out.println("The perimeter is: "+ s);
  12.         double area=Math.sqrt((((s*(s-a))*(s-b))*(s-c)));
  13.         System.out.print("Area of the triangle is: ");
  14.         System.out.printf("%.3f", area);
  15.     }
  16.     public static void Banner(){
  17.         System.out.println("Malachi Sor Homework 3.7");
  18.     }
  19. }
Add Comment
Please, Sign In to add comment