Java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter base: ");
double base = sc.nextDouble();
System.out.print("Enter height: ");
double height = sc.nextDouble();
double area = 0.5 * base * height;
System.out.println("Area of triangle = " + area);
sc.close();
}
}Output
Enter base: 10 Enter height: 5 Area of triangle = 25.0
We use the formula area = 1/2 × base × height.