Array-promo

Question

calculate the area of triangle.

				
					area of triangle =1/2x base x height
OUTPUT:
Enter base of triangle
12
Enter height of triangle
10
Area of triangle=60.0
				
			

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram

Code

				
					import java.util.Scanner;
public class areaOfTriangle
{  
    public static void main(String args[])  
    {  
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter base of triangle");
        double base=sc.nextDouble();
        System.out.println("Enter height of triangle");
        double height=sc.nextDouble();
        /*Formula of area of triangle =(1/2)*base of triangle *height of triangle*/
        double area=0.5*base*height;  
        System.out.println("Area of triangle="+area);  
     }  
}  

				
			

Coding Store

Leave a Reply

Your email address will not be published. Required fields are marked *