Pin It

How to calculate Area of Triangle through a Java program ?.

Program to calculate Area of Triangle in Java



import java.util.Scanner;

public class Triangle {

   public static void main(String[] args) {
      Scanner input = new Scanner(System.in);

      double base = 0;
      double height = 0;
      double area = 0;

      System.out.print("Enter the length of base of triangle : "); 
      base = input.nextDouble();

      System.out.print("Enter the length of height of triangle : "); 
      height = input.nextDouble();

      area = (base * height) / 2;
    
      System.out.println("");
      System.out.println("The Area of Triangle is : "
                  + area);

   }

}


Output of the program : 


Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot