Write a java program to find the minimum of two number using the if...else statement.

Q.7 Write a java program to find the minimum of two number using the if…else statement.

Solution :- 

public class AverageCalculator{

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        System.out.print(“Enter the first number: “);

        int num1 = scanner.nextInt();

        System.out.print(“Enter the second number: “);

        int num2 = scanner.nextInt();

        if (num1 < num2) {

            System.out.println(“The minimum number is: ” + num1);

        } 

else 

{

            System.out.println(“The minimum number is: ” + num2);

        }

 

    }

}

Output :- 

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.