Java - Get the Smallest Of 3 Numbers

Description

Get the Smallest Of 3 Numbers

Demo

import java.util.Scanner;


public class Main {

  public static void main(String[] args) {
      System.out.print("Getting the smallest of 3 numbers:");
      Scanner input = new Scanner(System.in);        
      double smallest = input.nextDouble();
      double second = input.nextDouble();
      if (smallest>second){
        smallest=second;/*from w  w  w  .j a  v  a  2s .  c o m*/
      }
      double third = input.nextDouble();
      if (smallest>third){
        smallest=third;
      }
      input.close();
      System.out.print("The smallest number is: "+smallest);
  }

}

Related Topic