123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. int sum=num1+num2;
  10. return sum;
  11. }
  12. /**
  13. * Add two number together
  14. * @param num1 first number
  15. * @param num2 second number
  16. * @return the sum of the two numbers
  17. */
  18. public double add(double num1, double num2){
  19. double sum=num1+num2;
  20. return sum;
  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. return number/2.0;
  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) {
  37. return true;
  38. } else if (number%2 == 0){
  39. return false;
  40. }
  41. return false;
  42. }
  43. /**
  44. * Multiply the number by itself
  45. * @param number the number given
  46. * @return the result of the number multiply by itself
  47. */
  48. public int square(int number) {
  49. double num= number*number;
  50. return (int) num;
  51. }
  52. }