Computer Science, asked by harshithaharshi07, 4 months ago

Write a java code to calculate the area of the triangle using the formula area= 1/2bh​

Answers

Answered by sayan3817
1

Answer:

import java.util.*;

class Triangle

{

public static void main();

{

Scanner sc = new Scanner (System.in);

System.out.println ("Enter the base of the triangle");

int b = sc.nextInt();

System.out.println("Enter the height of the triangle");

int h = sc.nextInt();

double area = 1/2.0 *b * h;

System.out.println("Area of the triangle =" + area);

}

}

Similar questions