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