forked from ChrisMayfield/ThinkJavaCode2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquare.java
More file actions
15 lines (13 loc) · 672 Bytes
/
Copy pathSquare.java
File metadata and controls
15 lines (13 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// David Anderson
public class Square{
public static void main(String[] args){
System.out.println("Is (5, 5) inside a square of size 5?: " + isInSquare(5, 5, 5));
System.out.println("Is (6, 5) inside a square of size 5?: " + isInSquare(6, 5, 5));
System.out.println("Is(0, 0) inside a square of size 100?: " + isInSquare(0, 0, 100));
System.out.println("Is -99, 0 inside a square of size 100?: " + isInSquare(-99, 0, 100));
System.out.println("Is (50, 61) inside a square of size 75?: " + isInSquare(50, 61, 75));
}
public static boolean isInSquare(int x, int y, int size){
return x >= 0 && y >=0 && x <= size && y <= size;
}
}