|
@@ -1,54 +1,55 @@
|
1
|
1
|
public class MathUtilities{
|
2
|
|
- /**
|
3
|
|
- * Add two number together
|
4
|
|
- * @param num1 first number
|
5
|
|
- * @param num2 second number
|
6
|
|
- * @return the sum of the two numbers
|
7
|
|
- */
|
8
|
|
- public int add(int num1, int num2){
|
9
|
|
- return num1+num2;
|
10
|
|
- }
|
|
2
|
+ /**
|
|
3
|
+ * Add two number together
|
|
4
|
+ * @param num1 first number
|
|
5
|
+ * @param num2 second number
|
|
6
|
+ * @return the sum of the two numbers
|
|
7
|
+ */
|
|
8
|
+ public int add(int num1, int num2){
|
|
9
|
+ return num1+num2;
|
|
10
|
+ }
|
11
|
11
|
|
12
|
|
- /**
|
13
|
|
- * Add two number together
|
14
|
|
- * @param num1 first number
|
15
|
|
- * @param num2 second number
|
16
|
|
- * @return the sum of the two numbers
|
17
|
|
- */
|
18
|
|
- public double add(double num1, double num2){
|
19
|
|
- return num1 + num2;
|
20
|
|
- }
|
|
12
|
+ /**
|
|
13
|
+ * Add two number together
|
|
14
|
+ * @param num1 first number
|
|
15
|
+ * @param num2 second number
|
|
16
|
+ * @return the sum of the two numbers
|
|
17
|
+ */
|
|
18
|
+ public double add(double num1, double num2){
|
|
19
|
+ return num1 + num2;
|
|
20
|
+ }
|
21
|
21
|
|
22
|
|
- /**
|
23
|
|
- * Get half the value of the number
|
24
|
|
- * @param number the number given
|
25
|
|
- * @return the half of the number in double
|
26
|
|
- */
|
27
|
|
- public double half(int number) {
|
28
|
|
- double num= number/ 2;
|
29
|
|
- return (double )num;
|
30
|
|
- }
|
|
22
|
+ /**
|
|
23
|
+ * Get half the value of the number
|
|
24
|
+ * @param number the number given
|
|
25
|
+ * @return the half of the number in double
|
|
26
|
+ */
|
|
27
|
+ public double half(int number) {
|
|
28
|
+
|
|
29
|
+ return number/2.0;
|
|
30
|
+ }
|
31
|
31
|
|
32
|
|
- /**
|
33
|
|
- * Determine if the number is odd
|
34
|
|
- * @param number the number given
|
35
|
|
- * @return true if the number is odd, false if it is even
|
36
|
|
- */
|
37
|
|
- public boolean isOdd(int number){
|
38
|
|
-
|
39
|
|
-
|
40
|
|
-
|
41
|
|
- return false;
|
42
|
|
- }
|
|
32
|
+ /**
|
|
33
|
+ * Determine if the number is odd
|
|
34
|
+ * @param number the number given
|
|
35
|
+ * @return true if the number is odd, false if it is even
|
|
36
|
+ */
|
|
37
|
+ public boolean isOdd(int number){
|
|
38
|
+ if (number %2 !=0){
|
|
39
|
+ return true;
|
|
40
|
+ } else if (number %2==0){
|
|
41
|
+ return false;
|
|
42
|
+ }
|
|
43
|
+ return false;
|
|
44
|
+ }
|
43
|
45
|
|
44
|
|
-
|
45
|
|
- /**
|
46
|
|
- * Multiply the number by itself
|
47
|
|
- * @param number the number given
|
48
|
|
- * @return the result of the number multiply by itself
|
49
|
|
- */
|
50
|
|
- public int square(int number) {
|
51
|
|
- return number * number;
|
52
|
|
- }
|
|
46
|
+ /**
|
|
47
|
+ * Multiply the number by itself
|
|
48
|
+ * @param number the number given
|
|
49
|
+ * @return the result of the number multiply by itself
|
|
50
|
+ */
|
|
51
|
+ public int square(int number) {
|
|
52
|
+ return number * number;
|
|
53
|
+ }
|
53
|
54
|
|
54
|
55
|
}
|