|
@@ -1,3 +1,7 @@
|
|
1
|
+import java.util.*;
|
|
2
|
+
|
|
3
|
+import java.text.DecimalFormat;
|
|
4
|
+
|
1
|
5
|
public class MathUtilities{
|
2
|
6
|
/**
|
3
|
7
|
* Add two number together
|
|
@@ -6,7 +10,8 @@ public class MathUtilities{
|
6
|
10
|
* @return the sum of the two numbers
|
7
|
11
|
*/
|
8
|
12
|
public int add(int num1, int num2){
|
9
|
|
- return -1;
|
|
13
|
+ int solution = num1 + num2;
|
|
14
|
+ return solution;
|
10
|
15
|
}
|
11
|
16
|
|
12
|
17
|
/**
|
|
@@ -16,7 +21,8 @@ public class MathUtilities{
|
16
|
21
|
* @return the sum of the two numbers
|
17
|
22
|
*/
|
18
|
23
|
public double add(double num1, double num2){
|
19
|
|
- return -1;
|
|
24
|
+ double solution = num1 + num2;
|
|
25
|
+ return solution;
|
20
|
26
|
}
|
21
|
27
|
|
22
|
28
|
/**
|
|
@@ -25,7 +31,11 @@ public class MathUtilities{
|
25
|
31
|
* @return the half of the number in double
|
26
|
32
|
*/
|
27
|
33
|
public double half(int number) {
|
28
|
|
- return -1;
|
|
34
|
+ double ohokay = number / 2;
|
|
35
|
+ DecimalFormat solution = new DecimalFormat(".#");
|
|
36
|
+ String theone = solution.format(ohokay);
|
|
37
|
+ double answer = (double) ohokay;
|
|
38
|
+ return answer;
|
29
|
39
|
}
|
30
|
40
|
|
31
|
41
|
/**
|
|
@@ -34,7 +44,8 @@ public class MathUtilities{
|
34
|
44
|
* @return true if the number is odd, false if it is even
|
35
|
45
|
*/
|
36
|
46
|
public boolean isOdd(int number){
|
37
|
|
- return false;
|
|
47
|
+ if ((number % 2) != 0) {
|
|
48
|
+ return true;} else { return false;}
|
38
|
49
|
}
|
39
|
50
|
|
40
|
51
|
|
|
@@ -44,7 +55,8 @@ public class MathUtilities{
|
44
|
55
|
* @return the result of the number multiply by itself
|
45
|
56
|
*/
|
46
|
57
|
public int square(int number) {
|
47
|
|
- return -1;
|
|
58
|
+ int solution = number * number;
|
|
59
|
+ return solution;
|
48
|
60
|
}
|
49
|
61
|
|
50
|
62
|
}
|