This program converts any number that you enter to a binary number. For more information on binary numbers, visit:
http://www.math.grin.edu/~rebelsky/Courses/152/97F/Readings/student-binary
:)
This program converts any number that you enter to a binary number. For more information on binary numbers, visit:
http://www.math.grin.edu/~rebelsky/Courses/152/97F/Readings/student-binary
:)
import java.io.*;
class decimal_binary
{
static void convert()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter a number: ");
int n=Integer.parseInt(br.readLine());
String s="";
for(;n>0;)
{
int q=n%2;
s=Integer.toString(q)+s;
n/=2;
}
System.out.println(s);
}
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.