Guest User

06. Formatting Numbers

a guest
Aug 27th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class _06_FormattingNumbers {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int a = scanner.nextInt();
  8.         float b = scanner.nextFloat();
  9.         float c = scanner.nextFloat();
  10.  
  11.         String aToHex = Integer.toHexString(a).toUpperCase();
  12.         int aToBinary = Integer.parseInt(Integer.toBinaryString(a));
  13.  
  14.         System.out.printf("|%1$-10s|%2$010d|%3$10.2f|%4$-10.3f|", aToHex, aToBinary, b, c);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment