MathUtilities.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 number = (num1 + num2);
  10. return number;
  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 stuff = (num1 + num2);
  20. return stuff;
  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. double answer = (double)(number/2);
  29. return answer;
  30. }
  31. /**
  32. * Determine if the number is odd
  33. * @param number the number given
  34. * @return true if the number is odd, false if it is even
  35. */
  36. public boolean isOdd(int number){
  37. if(number % 2 != 0){
  38. return true;
  39. } else{
  40. return false;
  41. }
  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. return (number*number);
  50. }
  51. }