This Java program prompts the user to input two numbers and then finds and prints the maximum of the two numbers using conditional statements.
import java.util.Scanner; class Maximum_Number { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the Number1 : "); int num1 = input.nextInt(); System.out.print("Enter the Number2 : "); int num2 = input.nextInt(); if(num1>num2) System.out.println("Maximum Number is " +num1); else if(num1<num2) System.out.println("Maximum Number is " +num2); else System.out.println("Both are Equal " +num1); } }
Enter the Number1 : 56 Enter the Number2 : 34 Maximum Number is 56
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions