AlexKondov

Java Smallest of Three Numbers

May 13th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class SmallestOfThreeNumbers {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner input = new Scanner(System.in);
  8.         int a = input.nextInt();
  9.         int b = input.nextInt();
  10.         int c = input.nextInt();
  11.        
  12.         int smallest = a;
  13.        
  14.         if (smallest > b) {
  15.             smallest = b;
  16.             if (smallest > c) {
  17.                 smallest = c;
  18.             }
  19.         }
  20.         else if (smallest > c) {
  21.             smallest = c;
  22.             if (smallest > b) {
  23.                 smallest = b;
  24.             }
  25.         }
  26.        
  27.         System.out.println(smallest);
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment