This program is A decimal to/from binary number converter problem. This is a pre
ID: 3842819 • Letter: T
Question
This program is A decimal to/from binary number converter problem. This is a pretty beginner class so we haven’t discussed any major topics. We are using abstract methods and exception handling to deal with this problem/ arrays and other basic java topics binary object files.I will include an example as reference to how much we have used. Essentially this is an excersie A decimal to/from binary number converter, please include srcshot of output.
The first step in this project is to decide which types of components you’ll need and the design layout of those components in your window.
Decide how your program will work:
Your screen should have two text areas, one which will contain a decimal number and the other which will contain a binary string of digits.
Option A: One possible configuration is to use two buttons: one to convert a decimal number to binary and another to convert a binary string of digits to a decimal number
Option B: Another second option is to use a single button which converts the contents of whichever text area has something in it to the other text area (presumably empty).
Option C: A third option might be to use no buttons at all. Instead, convert the contents of whichever text area is active when the user enters a number and presses the “Enter” key. (The scope of this option is probably beyond what we’ve learned up to this point, but you can give it a try, if you wish.)
Next, design the look of translator’s screen:
Determine the layout of your screen (frame). It should contain:
A title for the window frame in the top left corner
A title for your main screen (in the top center of the content pane)
Labels for the text areas
Button or buttons to convert the contents of one text area from or to binary
A third button to close the window
Once you have your screen layout figured out, determine the panels and their layout managers which will best handle your application.
The next step might be to create each component and place it on a JFrame.
Create your class with the appropriate type of frame, then instantiate the class in main
Make the frame visible
Set the window frame’s title to include your name plus “Converter”
Set the background color of the frame to a soft, pleasing color
Create all necessary panels and layouts
Create and add a title for your main screen
Create and add the two text areas and their labels
Create one button for each text area (Option A) or just a single button (Option B)
Create a third button to close the screen
Determine the look-and-field of each component (color, size, and content)
Modify the layout so that it is pleasing to the eye and intuitive to use.
Now you have a pleasant-looking screen which is completely non-functional. Add the functionality to each component on the screen
Add listeners to the button (or buttons).
When the user enters a decimal number in the text box for decimal numbers and the user presses the button to convert from decimal to binary, place the binary equivalent in the other text box. Use the Integer.toBinaryString(n) method to convert from a decimal number (in n) to a binary string,
If the user enters an invalid number, then place a message in the box for binary numbers which indicates there is an error
When the user enters a binary number in the text box for binary digits and the user presses the button to convert from binary to decimal, place the decimal equivalent in the other text box. Use the Integer.parseInt(s, 2) method to convert a binary string (in s) to a decimal number
If the user enters an invalid binary number, then place a message in the box for decimal numbers which indicates there is an error
When the user clicks on the button to close the application, the program stops
Submit listings for class(es) in your project. Test your program with at least 3 different numbers converted either to or from decimal, and PrintScreen the results.
EXAMPLE OF CODE NOT PART OF THE QUESTION FOR CONTEXT
Explanation / Answer
class DecimalBinaryExample{ public static void main(String a[]){ System.out.println("Binary representation of 124: "); System.out.println(Integer.toBinaryString(124)); System.out.println(" Binary representation of 45: "); System.out.println(Integer.toBinaryString(45)); System.out.println(" Binary representation of 999: "); System.out.println(Integer.toBinaryString(999)); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.