Program to calculate Area of Triangle in Java
Output of the program :
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 :