// Arup Guha
// 7/20/04
// Solution to BHCSI Program: Convert
// This program takes in a positive integer value from the user 
// in base 10 and converts it into an unsigned binary value.

import java.io.*;

public class Binary {

  public static void main(String[] args) throws IOException {

    BufferedReader stdin = new BufferedReader
				(new InputStreamReader(System.in));

    // Read in the base 10 value.
    System.out.println("What decimal number would you like to convert to binary?");
    int value = Integer.parseInt(stdin.readLine());

    // Initialize your answer.
    String ans = "";

    // Loop through until there are no more digits to compute.
    while (value > 0) {

      // Get the next least significant digit.
      int bindigit = value%2;

      // Assign the string equivalent to that digit. 
      String digit;
      if (bindigit == 0)
        digit = "0";
      else
        digit = "1";

      // Divide value by 2 to isolate the rest of the number.
      value /= 2;

      // Concatenate this new digit to the front of the existing number.
      ans = digit + ans;

    }

    // Print out the answer.
    System.out.println("Your binary number is "+ans);
  }
}

   
