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