Write a Java Program to input two angles from user and find third angle of the triangle. How to find all angles of a triangle if two angles are given by user using Java programming. Java program to calculate the third angle of a triangle if two angles are given.

**Required knowledge**

Arithmetic operators, Data types, Basic input/output

**Properties of triangle**

Sum of angles of a triangle is 180°.

Let us apply basic math to derive formula for third angle. If two angles of a triangle are given, then third angle of triangle is given by -

c=180-(a+b)

**Logic to find third angle of a triangle**

Step by step descriptive logic to find third angle of a triangle -

Input two angles of triangle from user. Store it in some variable say a and b.

Compute third angle of triangle using formula c = 180 - (a + b).

Print value of third angle i.e. print c.

**Program to find angles of a triangle**

/** * Java program to find all angles of a triangle if two angles are given */ import java.util.Scanner; class Test { public static void main(String args[]) { int a, b, c; Scanner op=new Scanner(System.in); /* Input two angles of the triangle */ System.out.print("Enter First angles of triangle: "); a=op.nextInt(); System.out.print("Enter Second angles of triangle: "); b=op.nextInt();; /* Compute third angle */ c = 180 - (a + b); /* Print value of the third angle */ System.out.println("Third angle of the triangle = "+c); } }

**Output:**

Enter First angles of triangle: 70 Enter Second angles of triangle: 80 Third angle of the triangle = 30