Java Program To Find Perimeter of Triangle

This is a Java Program to Find the Perimeter of a Triangle. 

formula to calculate perimeter of triangle: 

Perimeter of triangle=(t1+t2+t3

Enter the three sides of the triangle as inputs. Calculate the perimeter by utilizing formula and get the ideal output. 

Here is the source code of the Java Program to Find the Perimeter of Triangle. The Java program is effectively ordered and kept running on a Windows framework.

Java Program To Find Perimeter of triangle
import java.util.Scanner;
class Triangle
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the sides of triangle : ");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(a+b>c && b+c>a && a+c>b && a!=0 && b!=0 && c!=0)
System.out.println("Perimeter of triangle : " + (a+b+c));
else
System.out.println("Invalid sides entered.");
}

OUTPUT:
Enter the sides of triangle : 5 12 13
Perimeter of triangle : 30

tags : java , java programs , java programming language , java code , c , programs , c++ , programs of c++ , code camp , perimeter of triangle , tutorialspoint , java tutorialspoint

1 Comments

Previous Post Next Post