Computer Science, asked by toplayer, 1 year ago

write a program in java to convert a decimal number to binary....

Answers

Answered by Anonymous
3
class DecimalBinaryExample{ public static void main(String a[]){ System.out.println("Binary representation of 124: "); System.out.println(Integer.toBinaryString(124)); System.out.println("\nBinary representation of 45: "); System.out.println(Integer.toBinaryString(45)); System.out.println("\nBinary representation of 999: "); System.out.println(Integer.toBinaryString(999)); } }

toplayer: but i dont knw this method........can u explain me wid scanner of ISR???
Answered by 22Aryan22
1
The program output is also shown below.

1. import java.util.Scanner;
2. public class Convert.
3. public static void main(String[] args)
4. int n, count = 0, a;
5. String x = "";
6. Scanner s = new Scanner(System. in);
7. System. out. print("Enter any decimal number:");
8. n = s. nextInt();

I hope this will help you


toplayer: no this wasnt helpful 2 me...
Similar questions