1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. }
  11. /**
  12. * Add two number together
  13. * @param num1 first number
  14. * @param num2 second number
  15. * @return the sum of the two numbers
  16. */
  17. public double add(double num1, double num2){
  18. return num1 + num2;
  19. }
  20. /**
  21. * Get half the value of the number
  22. * @param number the number given
  23. * @return the half of the number in double
  24. */
  25. public double half(int number) {
  26. double temp = (double) number;
  27. double result = temp / 2;
  28. return result;
  29. }
  30. /**
  31. * Determine if the number is odd
  32. * @param number the number given
  33. * @return true if the number is odd, false if it is even
  34. */
  35. public boolean isOdd(int number){
  36. if(number % 2 == 0){return false;}else{return true;}
  37. }
  38. /**
  39. * Multiply the number by itself
  40. * @param number the number given
  41. * @return the result of the number multiply by itself
  42. */
  43. public int square(int number) {
  44. return number*number;
  45. }
  46. }