Find Maximum and Minimum of two numbers using Absolute function | Java program to find maximum and minimum using Absolute function ; Function to return maximum among the two numbers ; Function to return minimum among the two numbers ; Driver code ; Displaying the maximum value ; Displaying the minimum value
class GFG { static int maximum ( int x , int y ) { return ( ( x + y + Math . abs ( x - y ) ) / 2 ) ; } static int minimum ( int x , int y ) { return ( ( x + y - Math . abs ( x - y ) ) / 2 ) ; } public static void main ( String [ ] args ) { int x = 99 , y = 18 ; System . out . println ( " Maximum : ▁ " + maximum ( x , y ) ) ; System . out . println ( " Minimum : ▁ " + minimum ( x , y ) ) ; } }