Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. package assignment.pkg6.pkg1;
  2.  
  3. public class Assignment61 {
  4.  
  5.  
  6. public static void main(String[] args) {
  7. // Invoke the max emthod with int parameters
  8. System.out.println("The maximum of 3 and 4 is " + max(3,4));
  9.  
  10. // Invoke the max method with the double parameters
  11. System.out.println("The maximum of 3.0 and 5.4 is " + max(3.0,5.4));
  12.  
  13. // Invoke the max method with three double parameters
  14. System.out.println("The maximum of 3.0, 5.4, and 10.14 is " + max(3.0,5.4,10.14));
  15. }
  16. // return the max of two int values
  17. public static int max(int num1, int num2){
  18. if (num1 > num2)
  19. return num1;
  20. else
  21. return num2;
  22. }
  23. // Find the max of two double values
  24. public static double max (double num1, double num2){
  25. if (num1 > num2)
  26. return num1;
  27. else
  28. return num2;
  29. }
  30. // return the max of three double values
  31. public static double max (double num1, double num2, double num3){
  32. return max (max(num1, num2), num3);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement