forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethodChecks.java
More file actions
40 lines (34 loc) · 1021 Bytes
/
MethodChecks.java
File metadata and controls
40 lines (34 loc) · 1021 Bytes
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
public class MethodChecks
{
public static void main(String[] args)
{
System.out.println(isDivisible(3,5));
System.out.println(isDivisible(10,5));
System.out.println();
System.out.println(isTriangle(12, 1, 3));
System.out.println(isTriangle(4, 5, 9));
System.out.println(isTriangle(61, 455, 288));
System.out.println(isTriangle(15, 16, 12));
System.out.println(isTriangle(61, 455, 28));
System.out.println(isTriangle(6, 45, 28));
System.out.println(isTriangle(10, 8,19));
}
private static boolean isDivisible(int n, int m)
{
if (n % m == 0)
return true;
else
return false;
}
private static boolean isTriangle(int a, int b, int c)
{
boolean result = true;
if ( a > (b + c))
result = false;
else if (b > (a + c))
result = false;
else if (c > (b + c))
result = false;
return result;
}
}