Advertisement
IvanKrastev

Homework Java Syntax Problem 6 Formating Numbers

Jan 26th, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4.  
  5. public class Problem_6_FormatingNumbers {
  6.  
  7.     public static void main(String[] args) {
  8.        
  9.         Scanner scan= new Scanner(System.in);
  10.        
  11.  
  12.         int a = scan.nextInt();
  13.         float b = scan.nextFloat();
  14.         float c = scan.nextFloat();
  15.        
  16.        
  17.        
  18.         System.out.printf("|%-10X", a);
  19.         System.out.printf(String.format("|%10s", Integer.toBinaryString(a)).replace(" ", "0"));
  20.         System.out.printf("|%10.2f",b);
  21.         System.out.printf("|%-10.3f|",c);
  22.        
  23.        
  24.        
  25.        
  26.        
  27.  
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement