-
Notifications
You must be signed in to change notification settings - Fork 0
/
PointsInsideHouse.java
33 lines (23 loc) · 1.05 KB
/
PointsInsideHouse.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
import java.util.Scanner;
public class PointsInsideHouse {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String inputStr = input.nextLine();
String data[] = inputStr.split(" ");
double x = Float.parseFloat(data[0]);
double y = Float.parseFloat(data[1]);
double leftSide = ( (12.5 - 17.5)*(y - 3.5) - (8.5 - 3.5)*(x - 17.5) );
double rightSide = ( (22.5 - 17.5)*(y - 3.5) - (8.5 - 3.5)*(x - 17.5) );
boolean leftRoof = leftSide <= 0.0;
boolean rightRoof = rightSide >= 0.0;
boolean roof = leftRoof == true && rightRoof == true && y <= 8.5;
boolean leftWall = y >= 8.5 && y <= 13.5 && x >= 12.5 && x <= 17.5;
boolean rightWall = y >= 8.5 && y <= 13.5 && x >= 20 && x <= 22.5;
boolean walls = leftWall == true || rightWall == true;
if(roof == true || walls == true) {
System.out.println("Inside");
} else {
System.out.println("Outside");
}
}
}