0% found this document useful (0 votes)
42 views

Java Program To Find Area of Triangle With Output and Explanation

This document provides a Java program to calculate the area of a triangle given the base and height. It explains that the area of a triangle is calculated by multiplying the base and height and dividing by 2. The program asks the user to input the base and height, multiplies them, divides by 2, and displays the calculated area. The formula and program code are provided.

Uploaded by

A- S
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Java Program To Find Area of Triangle With Output and Explanation

This document provides a Java program to calculate the area of a triangle given the base and height. It explains that the area of a triangle is calculated by multiplying the base and height and dividing by 2. The program asks the user to input the base and height, multiplies them, divides by 2, and displays the calculated area. The formula and program code are provided.

Uploaded by

A- S
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Java Program to Find Area of Triangle With Output and

Explanation
Problem:- Java program to find Area of Triangle with Output
and Explanation or Java program to calculate area of Triangle
or Java Program to Find the Area of a Triangle Given Three
Sides or How to Calculate Area of Triangle in Java or How to
calculate Area of Triangle through a Java program or Java
Program To Calculate Area Of Right Triangle.

Explanation:- For finding the Area of Triangle we need to


height and base of the triangle after that just put the height
and base in given below formula, here you are done now the
program will return the area of the triangle. We know that if
the triangle is right angle than we can find the area of
triangle by given formula show that

Formula:-
Area of Triangle = ( Height * Base ) / 2

See Also:- C Program To Display Area Of Triangle


Java Program to Find Area of Triangle With Output and
Explanation
/* Program By Ghanendra Yadav
Visit http://www.programmingwithbasics.com/
*/
import java.util.Scanner;
class trianglearea
{
public static void main(String args[])
{
Scanner scanner = new Scanner(System.in);

System.out.println("Enter the width of the Triangle:");


double base = scanner.nextDouble();
System.out.println("Enter the height of the Triangle:");
double height = scanner.nextDouble();

double area = (base* height)/2;


System.out.println("Area of Triangle is: " + area);
}
}

You might also like