Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Problem4
  4. {
  5.   public static void main(String[] args)
  6.   {
  7.     Scanner in = new Scanner(System.in);
  8.     int numberDecimal = in.nextInt();
  9.  
  10.     StringBuilder binary = new StringBuilder();
  11.  
  12.  
  13.     while (numberDecimal > 0) {
  14.       binary.append(numberDecimal % 2);
  15.       numberDecimal = numberDecimal / 2;
  16.     }
  17.     System.out.print(binary.reverse());
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement