Advertisement
Fundamentalen

FormattingNumbers

May 14th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class FormattingNumbers {
  5.  
  6.     public static void main(String[] args) {
  7.        
  8.         Scanner input = new Scanner(System.in);
  9.        
  10.         int a = input.nextInt();
  11.         double b = input.nextDouble();
  12.         double c = input.nextDouble();
  13.        
  14.         if (a >= 0 && a <= 500) {
  15.             String binary = String.format("%10s", Integer.toBinaryString(a)).replace(' ', '0');
  16.            
  17.             System.out.printf("|%-10X|%s|%10.2f|%-10.3f|", a, binary, b, c);
  18.         }
  19.  
  20.     }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement