Question 73 : Write a program in Java to convert a decimal number into binary notation.
Java Program :
class dectobin
{
static void main(int m)
{
String s="";
int n=m;
while(n>0)
{
s=String.valueOf(n%2)+s;
n=n/2;
}
System.out.print("The binary value of "+m+" is : "+s);
}
}
Java Program :
class dectobin
{
static void main(int m)
{
String s="";
int n=m;
while(n>0)
{
s=String.valueOf(n%2)+s;
n=n/2;
}
System.out.print("The binary value of "+m+" is : "+s);
}
}
i want that if i write a normal program in blue j and i want to convert it into a application (like printing factors of no.)then how do i convert it into a application
ReplyDeleteActually, BlueJ doesn't allow creation of applications as such. But I have a few alternatives :
Delete1) The easiest is to learn to create an applet in Java. Applet is just like an application, but it runs only on a server(or a browser window). For an example, visit the link below :
http://icse-java.blogspot.com/2011/09/applet-4-change-background.html
http://icse-java.blogspot.com/2011/09/applet-3-colour-change_11.html
2) You can try to use the byte code generated by Java to be run by others in a Java Virtual Machine. I don't have much information on this one, you may try to get a little help from Google. I have had tried this, but without any good results. I will keep trying to solve your problem.
And yes, you might also create a .jar file from BlueJ -> Project -> Create Jar File. But this doesn't work for our program. Still give it a try.
DeleteThanks for sharing this post. How to convert Decimal number to binary number in java .
ReplyDeleteGood explanation. Nice blog.
ReplyDeleteThanks,
https://www.flowerbrackets.com/java-decimal-to-binary-using-tobinarystring-and-stack/
Please,solve this question.Q.Write a program in Java using scanner class to perform mathematical operations(addition/subtraction/ division/multiplication). The numbers and the operators will be inputted by the user.
ReplyDeleteAs soon as possible .