HW4.37

时间:2024-07-12 08:05:49

HW4.37

 import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("Enter the integer: ");
         int number = input.nextInt();

         input.close();

         String binaryString = "";

         while(number > 0)
         {
             binaryString = number % 2 + binaryString;
             number /= 2;
         }

         System.out.println(binaryString);
     }
 }

相关文章