Java Program to Find the Smallest Number Between Two Numbers Using the Library Method

Java program to find the smallest number between two numbers using the library method

// Java program to find the smallest number between two numbers 
// using the library method

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner X = new Scanner(System.in);

    double num1 = 0;
    double num2 = 0;

    System.out.print("Enter number1: ");
    num1 = X.nextDouble();

    System.out.print("Enter number2: ");
    num2 = X.nextDouble();

    System.out.print("Smallest number is: " + Math.min(num1, num2));
  }
}

Output

Enter number1: 23.56
Enter number2: 22.56
Smallest number is: 22.56
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment