Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- This program reads three integer values
- and prints out the smallest of the three.
- If the values are equal, print out only one of them.
- */
- public class Smallest
- {
- public static void main(String[] args)
- {
- // Print prompt to enter three integer values
- System.out.println("Please enter three integer values:");
- // Read in the three integer values
- Scanner in = new Scanner(System.in);
- int value1 = in.nextInt();
- int value2 = in.nextInt();
- int value3 = in.nextInt();
- // Determine and print out the smallest value
- int smallest = value1;
- if(smallest > value2){smallest = value2;}
- if(smallest > value3){smallest = value3;}
- System.out.println(smallest);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement