Advertisement
zornitza_gencheva

Problem 6. Formatting Numbers

May 15th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import java.util.Locale;
  2. import java.util.Scanner;
  3.  
  4. public class Problem06_Formatting_Numbers {
  5.  
  6. public static void main(String[] args) {
  7. // TODO Auto-generated method stub
  8. Locale.setDefault(Locale.ROOT);
  9. Scanner input = new Scanner(System.in);
  10. int a = input.nextInt();
  11. double b = input.nextDouble();
  12. double c = input.nextDouble();
  13.  
  14. String aHexString = Integer.toHexString(a).toUpperCase();
  15. String aBinary = String.format("%10s", Integer.toBinaryString(a)).replace(' ', '0');
  16. System.out.format("|%-10s|%s|%10.2f|%-10.0f|",aHexString,aBinary,b,c);
  17. }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement