Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

MAXIMUM OF THE 2 NUMBERS IN JAVA USING MATH.MAX

import java.util.*;
public class maximum
{
    public static void main()
    {
        System.out.println("ENTER THE TWO NUMBER TO CHECK THE MAXIMUM ONE");
        Scanner a = new Scanner (System.in);
        int b  = a.nextInt();
        int c = a.nextInt();
        int d = Math.max(b,c); 
        System.out.println("MAXIMUM BETWEEN "+b+" and "+c+ " is " +d);
      //MADE BY CodeWithParth
    }
}
Comment

java max value between two numbers

//Using the built in Math library, you will have two options:

//import the library and then use the function
//(this is useful when your are going to use other functions defined in
//	java.lang.Math, such as "abs" or "min" ...)
import java.lang.Math;
public class MyClass {
    public static void main(String args[]) {
      int x=10;
      int y=25;
      int z= max(x, y);

      System.out.println("The max between the two values is " + z);
    }
}

//otherwise if you just need it once you can directly call 
//the function from the library
public class MyClass {
    public static void main(String args[]) {
      int x=10;
      int y=25;
      int z= Math.max(x, y);

      System.out.println("Sum of x+y = " + z);
    }
}
Comment

MAXIMUM OF THE 2 NUMBERS IN JAVA

import java.util.*;
public class maximum
{
    public static void main()
    {
        System.out.println("ENTER THE TWO NUMBER TO CHECK THE MAXIMUM ONE");
        Scanner a = new Scanner (System.in);
        int b  = a.nextInt();
        int c = a.nextInt();
        if (b>c)
        {
            System.out.println("MAXIMUM BETWEEN "+b+" and "+c+ " is " +b);
        }
        else if (c>b)
        {
            System.out.println("MAXIMUM BETWEEN "+b+" and "+c+ " is " +c);
        }
        else 
        {
            System.out.println("BOTH ARE EQUAL");
        }
        //MADE BY CodeWithParth
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java access a file 
Java :: java character for end of file 
Java :: loop array using stream java 
Java :: variables inside strings kotlin 
Java :: list constructor java 
Java :: Float to bytes java 
Java :: spring security logging 
Java :: java ints to color int 
Java :: FlutterSound.java uses or overrides a deprecated API. 
Java :: copy linked list 
Java :: how to convert iso-8859-1 to utf-8 in java 
Java :: what is outer class in java 
Java :: Java How to use Queue? 
Java :: single dex file error android 
Java :: android gridview item click effect ripple 
Java :: maximum integer in array java 
Java :: hasNext for scanner class java 
Java :: cookie jsf 
Java :: what are parameters in java 
Java :: dockerfile spring boot 
Java :: using a SnackBar on androidstudio 
Java :: add close button on right top corner of alert dialog box for android 
Java :: single linked list in java 
Java :: javafx get actionevent id 
Java :: java inner function 
Java :: how to use setonclicklistener from custom view in android 
Java :: retrofit post body 
Java :: display 2d array 
Java :: seek bar 
Java :: java wrapper classes 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =