Advertisement
velio84

_06_FormattingNumbers

Sep 8th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. package Homework2;
  2. import java.util.*;
  3. public class FormattingNumbers {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scan = new Scanner(System.in);
  7.         int a = scan.nextInt();
  8.         float b = scan.nextFloat();
  9.         float c = scan.nextFloat();
  10.        
  11.         String hexA = Integer.toHexString(a);
  12.         long binaryA = Long.parseLong(Integer.toBinaryString(a));
  13.        
  14.         System.out.printf("|%-10s|%010s|%10.2f|%-10.3f|", hexA, binaryA, b, c);
  15.        
  16.     }
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement