-
Notifications
You must be signed in to change notification settings - Fork 1
/
Q_14.java
53 lines (41 loc) · 1.34 KB
/
Q_14.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Muhammad Naveed
// (Sides of a Right Triangle) Write an application that reads
// three nonzero integers and determines and prints whether
// they could represent the sides of a right triangle.
import java.util.Scanner;
public class Q_14
{
public static void main(String[] args)
{
// Sides of triangle
int sideA, sideB, sideC;
// scanner object
Scanner sc = new Scanner(System.in);
// taking input
System.out.print("Enter first side : ");
sideA = sc.nextInt();
// taking input
System.out.print("Enter second side : ");
sideB = sc.nextInt();
// taking input
System.out.print("Enter third side : ");
sideC = sc.nextInt();
// closing the scanner
sc.close();
// taking squares of each side
int SquareSideA = (sideA * sideA);
int SquareSideB = (sideB * sideB);
int SquareSideC = (sideC * sideC);
// if triangle is right angle
if ((SquareSideA + SquareSideB) == SquareSideC
& (SquareSideA + SquareSideC) == SquareSideB
& (SquareSideC + SquareSideB) == SquareSideA )
{
System.out.println("Could be a right angle triangle");
}
else
{
System.out.println("Not a right angle triangle");
}
}
}