|
@@ -5,236 +5,110 @@ package com.zipcodewilmington.danny_do_better_exercises;
|
5
|
5
|
*/
|
6
|
6
|
public class MathUtilities {
|
7
|
7
|
|
8
|
|
- /**
|
9
|
|
- * @param baseValue starting value
|
10
|
|
- * @param difference value to add to starting value
|
11
|
|
- * @return sum of `baseValue` and `difference`
|
12
|
|
- */
|
13
|
8
|
public Integer add(int baseValue, int difference) {
|
14
|
|
- return null;
|
|
9
|
+ return baseValue + difference;
|
15
|
10
|
}
|
16
|
11
|
|
17
|
|
- /**
|
18
|
|
- * @param baseValue starting value
|
19
|
|
- * @param difference value to add to starting value
|
20
|
|
- * @return sum of `baseValue` and `difference`
|
21
|
|
- */
|
22
|
12
|
public Long add(long baseValue, long difference) {
|
23
|
|
- return null;
|
|
13
|
+ return baseValue + difference;
|
24
|
14
|
}
|
25
|
15
|
|
26
|
|
- /**
|
27
|
|
- * @param baseValue starting value
|
28
|
|
- * @param difference value to add to starting value
|
29
|
|
- * @return sum of `baseValue` and `difference`
|
30
|
|
- */
|
31
|
16
|
public Short add(short baseValue, short difference) {
|
32
|
|
- return null;
|
|
17
|
+ return (short) (baseValue + difference);
|
33
|
18
|
}
|
34
|
19
|
|
35
|
|
- /**
|
36
|
|
- * @param baseValue starting value
|
37
|
|
- * @param difference value to add to starting value
|
38
|
|
- * @return sum of `baseValue` and `difference`
|
39
|
|
- */
|
40
|
20
|
public Byte add(byte baseValue, byte difference) {
|
41
|
|
- return null;
|
|
21
|
+ return (byte) (baseValue + difference);
|
42
|
22
|
}
|
43
|
23
|
|
44
|
|
- /**
|
45
|
|
- * @param baseValue starting value
|
46
|
|
- * @param difference value to add to starting value
|
47
|
|
- * @return sum of `baseValue` and `difference`
|
48
|
|
- */
|
49
|
24
|
public Float add(float baseValue, float difference) {
|
50
|
|
- return null;
|
|
25
|
+ return baseValue + difference;
|
51
|
26
|
}
|
52
|
27
|
|
53
|
|
- /**
|
54
|
|
- * @param baseValue starting value
|
55
|
|
- * @param difference value to add to starting value
|
56
|
|
- * @return sum of `baseValue` and `difference`
|
57
|
|
- */
|
58
|
28
|
public Double add(double baseValue, double difference) {
|
59
|
|
- return null;
|
|
29
|
+ return baseValue + difference;
|
60
|
30
|
}
|
61
|
31
|
|
62
|
|
- /**
|
63
|
|
- * @param baseValue starting value
|
64
|
|
- * @param difference value to subtract from starting value
|
65
|
|
- * @return difference between `baseValue` and `difference`
|
66
|
|
- */
|
67
|
32
|
public Integer subtract(int baseValue, int difference) {
|
68
|
|
- return null;
|
|
33
|
+ return baseValue - difference;
|
69
|
34
|
}
|
70
|
35
|
|
71
|
|
- /**
|
72
|
|
- * @param baseValue starting value
|
73
|
|
- * @param difference value to subtract from starting value
|
74
|
|
- * @return difference between `baseValue` and `difference`
|
75
|
|
- */
|
76
|
36
|
public Long subtract(long baseValue, long difference) {
|
77
|
|
- return null;
|
|
37
|
+ return baseValue - difference;
|
78
|
38
|
}
|
79
|
39
|
|
80
|
|
- /**
|
81
|
|
- * @param baseValue starting value
|
82
|
|
- * @param difference value to subtract from starting value
|
83
|
|
- * @return difference between `baseValue` and `difference`
|
84
|
|
- */
|
85
|
40
|
public Short subtract(short baseValue, short difference) {
|
86
|
|
- return null;
|
|
41
|
+ return (short) (baseValue - difference);
|
87
|
42
|
}
|
88
|
43
|
|
89
|
|
- /**
|
90
|
|
- * @param baseValue starting value
|
91
|
|
- * @param difference value to subtract from starting value
|
92
|
|
- * @return difference between `baseValue` and `difference`
|
93
|
|
- */
|
94
|
44
|
public Byte subtract(byte baseValue, byte difference) {
|
95
|
|
- return null;
|
|
45
|
+ return (byte) (baseValue - difference);
|
96
|
46
|
}
|
97
|
47
|
|
98
|
|
- /**
|
99
|
|
- * @param baseValue starting value
|
100
|
|
- * @param difference value to subtract from starting value
|
101
|
|
- * @return difference between `baseValue` and `difference`
|
102
|
|
- */
|
103
|
48
|
public Float subtract(float baseValue, float difference) {
|
104
|
|
- return null;
|
|
49
|
+ return baseValue - difference;
|
105
|
50
|
}
|
106
|
51
|
|
107
|
|
- /**
|
108
|
|
- * @param baseValue starting value
|
109
|
|
- * @param difference value to subtract from starting value
|
110
|
|
- * @return difference between `baseValue` and `difference`
|
111
|
|
- */
|
112
|
52
|
public Double subtract(double baseValue, double difference) {
|
113
|
|
- return null;
|
|
53
|
+ return baseValue - difference;
|
114
|
54
|
}
|
115
|
55
|
|
116
|
|
-
|
117
|
|
- /**
|
118
|
|
- * @param dividend value to be divided
|
119
|
|
- * @param divisor value to divide by
|
120
|
|
- * @return division of `dividend` by `divisor
|
121
|
|
- */
|
122
|
56
|
public Integer divide(int dividend, int divisor) {
|
123
|
|
- return null;
|
|
57
|
+ return dividend / divisor;
|
124
|
58
|
}
|
125
|
59
|
|
126
|
|
- /**
|
127
|
|
- * @param dividend value to be divided
|
128
|
|
- * @param divisor value to divide by
|
129
|
|
- * @return division of `dividend` by `divisor
|
130
|
|
- */
|
131
|
60
|
public Long divide(long dividend, long divisor) {
|
132
|
|
- return null;
|
|
61
|
+ return dividend / divisor;
|
133
|
62
|
}
|
134
|
63
|
|
135
|
|
- /**
|
136
|
|
- * @param dividend value to be divided
|
137
|
|
- * @param divisor value to divide by
|
138
|
|
- * @return division of `dividend` by `divisor
|
139
|
|
- */
|
140
|
64
|
public Short divide(short dividend, short divisor) {
|
141
|
|
- return null;
|
|
65
|
+ return (short) (dividend / divisor);
|
142
|
66
|
}
|
143
|
67
|
|
144
|
|
- /**
|
145
|
|
- * @param dividend value to be divided
|
146
|
|
- * @param divisor value to divide by
|
147
|
|
- * @return division of `dividend` by `divisor
|
148
|
|
- */
|
149
|
68
|
public Byte divide(byte dividend, byte divisor) {
|
150
|
|
- return null;
|
|
69
|
+ return (byte) (dividend / divisor);
|
151
|
70
|
}
|
152
|
71
|
|
153
|
|
- /**
|
154
|
|
- * @param dividend value to be divided
|
155
|
|
- * @param divisor value to divide by
|
156
|
|
- * @return division of `dividend` by `divisor
|
157
|
|
- */
|
158
|
72
|
public Float divide(float dividend, float divisor) {
|
159
|
|
- return null;
|
|
73
|
+ return dividend / divisor;
|
160
|
74
|
}
|
161
|
75
|
|
162
|
|
- /**
|
163
|
|
- * @param dividend value to be divided
|
164
|
|
- * @param divisor value to divide by
|
165
|
|
- * @return division of `dividend` by `divisor
|
166
|
|
- */
|
167
|
76
|
public Double divide(double dividend, double divisor) {
|
168
|
|
- return null;
|
|
77
|
+ return dividend / divisor;
|
169
|
78
|
}
|
170
|
79
|
|
171
|
|
-
|
172
|
|
- /**
|
173
|
|
- * @param multiplicand value to be multiplied
|
174
|
|
- * @param multiplier value to multiply by
|
175
|
|
- * @return product of `multiplicand` by `multiplier`
|
176
|
|
- */
|
177
|
80
|
public Integer multiply(int multiplicand, int multiplier) {
|
178
|
|
- return null;
|
|
81
|
+ return multiplicand * multiplier;
|
179
|
82
|
}
|
180
|
83
|
|
181
|
|
- /**
|
182
|
|
- * @param multiplicand value to be multiplied
|
183
|
|
- * @param multiplier value to multiply by
|
184
|
|
- * @return product of `multiplicand` by `multiplier`
|
185
|
|
- */
|
186
|
84
|
public Long multiply(long multiplicand, long multiplier) {
|
187
|
|
- return null;
|
|
85
|
+ return multiplicand * multiplier;
|
188
|
86
|
}
|
189
|
87
|
|
190
|
|
- /**
|
191
|
|
- * @param multiplicand value to be multiplied
|
192
|
|
- * @param multiplier value to multiply by
|
193
|
|
- * @return product of `multiplicand` by `multiplier`
|
194
|
|
- */
|
195
|
88
|
public Short multiply(short multiplicand, short multiplier) {
|
196
|
|
- return null;
|
|
89
|
+ return (short) (multiplicand * multiplier);
|
197
|
90
|
}
|
198
|
|
- /**
|
199
|
|
- * @param multiplicand value to be multiplied
|
200
|
|
- * @param multiplier value to multiply by
|
201
|
|
- * @return product of `multiplicand` by `multiplier`
|
202
|
|
- */
|
|
91
|
+
|
203
|
92
|
public Byte multiply(byte multiplicand, byte multiplier) {
|
204
|
|
- return null;
|
|
93
|
+ return (byte) (multiplicand * multiplier);
|
205
|
94
|
}
|
206
|
95
|
|
207
|
|
- /**
|
208
|
|
- * @param multiplicand value to be multiplied
|
209
|
|
- * @param multiplier value to multiply by
|
210
|
|
- * @return product of `multiplicand` by `multiplier`
|
211
|
|
- */
|
212
|
96
|
public Float multiply(float multiplicand, float multiplier) {
|
213
|
|
- return null;
|
|
97
|
+ Float floatProduct = multiplicand * multiplier;
|
|
98
|
+ return floatProduct;
|
214
|
99
|
}
|
215
|
100
|
|
216
|
|
- /**
|
217
|
|
- * @param multiplicand value to be multiplied
|
218
|
|
- * @param multiplier value to multiply by
|
219
|
|
- * @return product of `multiplicand` by `multiplier`
|
220
|
|
- */
|
221
|
101
|
public Double multiply(double multiplicand, double multiplier) {
|
222
|
|
- return null;
|
|
102
|
+ Double doubleProduct = multiplicand * multiplier;
|
|
103
|
+ return doubleProduct;
|
223
|
104
|
}
|
224
|
105
|
|
225
|
|
-
|
226
|
|
- /**
|
227
|
|
- * @return true
|
228
|
|
- */
|
229
|
106
|
public Boolean returnTrue() {
|
230
|
|
- return null;
|
|
107
|
+ return true;
|
231
|
108
|
}
|
232
|
109
|
|
233
|
|
- /**
|
234
|
|
- * @return false
|
235
|
|
- */
|
236
|
110
|
public Boolean returnFalse() {
|
237
|
|
- return null;
|
|
111
|
+ return false;
|
238
|
112
|
}
|
239
|
113
|
|
240
|
114
|
}
|