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