Question #255520

Write the java program that calculates maximum of the given two numbers.

Expert's answer

import java.util.Scanner;
public class Main
{
    public static void main(String args[])
    {
        System.out.println("Enter the first Number");
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        System.out.println("Enter the second Number");
        int j = scan.nextInt();
        int max = i;
       if(j>i){
           max = j;
       }
       System.out.println("Maximum number is: "+max);
    }
}
LATEST TUTORIALS
APPROVED BY CLIENTS