Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DecimalToBinary {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Enter a decimal number: ");
- int decimalNumber = input.nextInt();
- String binaryNumber = Integer.toBinaryString(decimalNumber);
- System.out.println("Binary equivalent: " + binaryNumber);
- input.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment