Decimal to Binary Converter using Java GUI
Submitted by donbermoy on Monday, May 19, 2014 - 19:23.
In this tutorial, i will teach you how to create a program that converts an inputted decimal number into binary using Java GUI.
So, now let's start this tutorial!
1. Open JCreator or NetBeans and make a java program with a file name of decToBinary.java.
2. Import javax.swing package. Hence we will use a GUI (Graphical User Interface) here like the inputting the decimal number.
3. Initialize your variables in your Main, variable numInput as string and make it as an inputdialogbox. Variable n as integer that will parse the inputted value of numInput. And variable binary as integer that will hold the binary value of our input.
4. Compute the equivalent binary value of the inputted decimal number.
toBinaryString method converts any number into a binary value.
5. Lastly, display the output of the program using JOptionPane.showMessageDialog.
Output:
Here's the full code of this tutorial:
Hope this program helps! :)
Best Regards,
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- import javax.swing.*;
Add new comment
- 1623 views