-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay48_prob1.java
More file actions
51 lines (42 loc) · 1.68 KB
/
Day48_prob1.java
File metadata and controls
51 lines (42 loc) · 1.68 KB
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
/*
Deepak and Rachit are playing a game. Deepak will tell the three integers representing three sides of right angled triangle. Right angled Triangle have a rule that it always follows Pythagoras Theorem (Base^2 * Perpendicular^2 = Hypotenuse^2). Rachit need to check that whether the input provided by Deepak follows this rule or not. Write a program to help the Rachit to identify Triangle is Right angled or not. It will throw InvalidRightAngleTriangle exception when input is not following it.
Input Format
Three integer values representing three sides of triangle.
Constraints
Sides can not be greater than 20.
Output Format
Valid Triangle/ Invalid Triangle/ Invalid Input
*/
// Kirtan Jain
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
if(a>20 || a<1 || b>20 || b<1 || c>20 || c<1){
System.out.println("Invalid Input");
return;
}
if(a>=b && a>=c){
if(a*a == (b*b + c*c)){
System.out.println("Valid Triangle");
return;
}
}
if(b>=a && b>=c){
if(b*b == (a*a + c*c)){
System.out.println("Valid Triangle");
return;
}
}
if(c>=b && c>=a){
if(c*c == (b*b + a*a)){
System.out.println("Valid Triangle");
return;
}
}
System.out.println("Invalid Triangle");
}
}