MathUtilities.java 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package QuizWeek1;
  2. public class MathUtilities{
  3. /**
  4. * Add two number together
  5. * @param num1 first number
  6. * @param num2 second number
  7. * @return the sum of the two numbers
  8. */
  9. public int add(int num1, int num2){
  10. return (num1 + num2);
  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. return (num1 + num2);
  20. }
  21. /**
  22. * Get half the value of the number
  23. * @param number the number given
  24. * @return the half of the number in double
  25. */
  26. public double half(int number) {
  27. double newNum = (double)number;
  28. return (newNum / 2);
  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. boolean tOrF = true;
  37. if (number % 2 == 0){
  38. tOrF = false;}
  39. return tOrF;
  40. }
  41. /**
  42. * Multiply the number by itself
  43. * @param number the number given
  44. * @return the result of the number multiply by itself
  45. */
  46. public int square(int number) {
  47. return (number * number);
  48. }
  49. }