Advertisement
advictoriam

Untitled

Dec 7th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.    This program reads three integer values
  5.    and prints out the smallest of the three.
  6.    If the values are equal, print out only one of them.
  7. */
  8. public class Smallest
  9. {
  10.    public static void main(String[] args)
  11.    {
  12.       // Print prompt to enter three integer values
  13.       System.out.println("Please enter three integer values:");
  14.  
  15.       // Read in the three integer values
  16.       Scanner in = new Scanner(System.in);
  17.       int value1 = in.nextInt();
  18.       int value2 = in.nextInt();
  19.       int value3 = in.nextInt();
  20.  
  21.       // Determine and print out the smallest value
  22.       int smallest = value1;
  23.       if(smallest > value2){smallest = value2;}
  24.       if(smallest > value3){smallest = value3;}
  25.  
  26.       System.out.println(smallest);
  27.    }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement