Java

Program to find the smallest number among three numbers.

Program to find the smallest number among three numbers.
import java.util.Scanner;
public class demo1 
{
 public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        System.out.print("Input the first number: ");
        double a = input.nextDouble();
        System.out.print("Input the Second number: ");
        double b = input.nextDouble();
        System.out.print("Input the third number: ");
        double c = input.nextDouble();
        System.out.print("The smallest value is " + smallest(a, b, c)+"\n" );
    }
   public static double smallest(double a, double b, double c)
    {
        return Math.min(Math.min(a, b), c);
    }
}
Nikhil Juneja

Passionate software developer and technical contributor at TutorialsLink.