java program to input the three angles of a triangle and check whether it equilateral isosceles or a scalene triangle

Programming Example

Write a program to input the three angles of a triangle and check whether it forms a triangle or not, if it forms a triangle, check whether it is an equilateral, isosceles or a scalene triangle.

(Hint: To form a triangle, the sum of the angles should be 180 degrees.

To form an equilateral triangle every angle should be equal.

To form an isosceles triangle any two angles should be equal.

To form a scalene triangle all three angles should be different from each other.)

Solution

import java.util.*;
class Triangle
{
	public static void main(String ar[])
	{
		Scanner sc=new Scanner(System.in);
		int a,b,c;
		System.out.println(“Enter 3 angles:”);
		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();
		if(a+b+c==180)
		{
			if(a<90 && b<90 && c<90)
				System.out.println(“Acute angled triangle”);
			else if(a>90 || b>90 || c>90)
				System.out.println(“Obtuse angled triangle”);
			else
				System.out.println(“Right angled triangle”);
		}
		else
		System.out.println(“Cannot form a triangle”);
	}
}
Output

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad