12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. return ( (double) number/2);
  28. }
  29. /**
  30. * Determine if the number is odd
  31. * @param number the number given
  32. * @return true if the number is odd, false if it is even
  33. */
  34. public boolean isOdd(int number){
  35. if(number%2 == 0)
  36. {return false;
  37. }
  38. else
  39. {return true;}
  40. //return false;
  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. }