# Java program to enter the two angles of a triangle and find the third angle

ADVERTISEMENTS

Java program to enter the two angles of a triangle and find the third angle. There are you will learn how to find the third angle of a triangle in Java language.

**Base Knowledge:**

*a**° + b° + c° = 180°*

**Formula:**

*c**°** = 180**°** - (a**°** + b**°**)*

Let us understand this example through the Java program:

```
// Java program to find all angles of a triangle if two angles are given
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the two angles of triangle::\n");
int p = in.nextInt();
int q = in.nextInt();
int r;
// p, q, and r is all angles of the triangle
// Compute third angle
r = 180 - (p + q);
// Output
System.out.println("\nThird angle of the triangle = " + r + "\n");
}
}
```

**Output:**

Enter the two angles of triangle::

50

70

Third angle of the triangle = 60