Shavit

Three Digits Number V2

Oct 6th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class ThreeDigitNumber {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Scanner in = new Scanner (System.in);
  12.        
  13.         int num, hundreds, tens, ones;
  14.        
  15.         System.out.println("Enter a 3 digit number:");
  16.             num = Math.abs(in.nextInt());
  17.        
  18.         hundreds = num / 100;
  19.         tens = num % 100 / 10;
  20.         ones = num % 100 % 10;
  21.        
  22.         System.out.println("The order of the digits is: " + hundreds + ", " + tens + ", " + ones + ".");
  23.    
  24.         in.close();
  25.     }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment