Advertisement
Guest User

Untitled

a guest
Sep 4th, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1.  
  2. public class MaximumApp {
  3. public static void main(String[] args) {
  4.  
  5. int a,
  6. b,
  7. c,
  8. d;
  9. a = -10;
  10. b = 100;
  11. c = 20;
  12. d = 521;
  13.  
  14. int newMaxNumber = max(a, b);
  15. System.out.println(newMaxNumber);
  16. newMaxNumber = max(a, b, c);
  17. System.out.println(newMaxNumber);
  18. newMaxNumber = max(a, b, c, d);
  19. System.out.println(newMaxNumber);
  20. }
  21.  
  22. private static int max(int a, int b) {
  23. /**
  24. * This method describes the determination of the maximum
  25. * value among the variables passed to the method parameters.
  26. *
  27. * @param a variable of type Integer, it can be positive and negative values
  28. * @param b variable of type Integer, it can be positive and negative values
  29. * @return variable of type Integer, maximum value of 2 parameters
  30. */
  31. return (a > b) ? a : b;
  32. }
  33.  
  34. private static int max(int a, int b, int c) {
  35. /**
  36. * This method describes the determination of the maximum
  37. * value among the variables passed to the method parameters.
  38. *
  39. * @param a variable of type Integer, it can be positive and negative values
  40. * @param b variable of type Integer, it can be positive and negative values
  41. * @param c variable of type Integer, it can be positive and negative values
  42. * @return variable of type Integer, maximum value of 3 parameters
  43. */
  44. int newCheckNumb;
  45. newCheckNumb = max(a, b);
  46. return (newCheckNumb > c) ? newCheckNumb : c;
  47. }
  48.  
  49. private static int max(int a, int b, int c, int d) {
  50. /**
  51. * This method describes the determination of the maximum
  52. * value among the variables passed to the method parameters.
  53. *
  54. * @param a variable of type Integer, it can be positive and negative values
  55. * @param b variable of type Integer, it can be positive and negative values
  56. * @param c variable of type Integer, it can be positive and negative values
  57. * @param d variable of type Integer, it can be positive and negative values
  58. * @return variable of type Integer, maximum value of 4 parameters
  59. */
  60. int newCheckNumb;
  61. newCheckNumb = max(a, b, c);
  62. return (newCheckNumb > d) ? newCheckNumb : d;
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement