Java Reference
In-Depth Information
number in the "Operand" text field. Because values of type double are, in effect,
approximate values, it makes no sense to test for equality with 0.0 . Consider an
operand to be “equal to zero” if it is in the range -1.0e-10 to +1.0e-10 .
4. (The Swing part of this project is pretty easy, but to do this programming project
you need to know how to convert numbers from one base to another.) Write a
program that converts integers from base ten (ordinary decimal) notation to base
two notation. Use Swing to perform input and output via a window interface. The
user enters a base ten numeral in one text field and clicks a button with "Convert"
written on it; the equivalent base two numeral then appears in another text field.
Be sure to label the two text fields. Include a "Clear" button that clears both text
fields when clicked. ( Hint: Include a private method that converts the string for a
base ten numeral to the string for the equivalent base two numeral.)
5. Re-do or do for the first time the trivia game described in Programming
Projects 6.12 and 6.13, except create a GUI for the game interface. Use a layout of
your choice with the appropriate text fields, labels, and buttons to implement your
design. The game should ask only one question at a time and output the correct
answer if the player answers a question incorrectly. When all questions have been
answered, show the final score and exit the program.
6. Write a program that implements a simple text editor. Use a JTextArea for the
area that the user can enter text. Add a button that allows the user to save the text
to a file and a button that allows the user to load the text from a file.
Search WWH ::




Custom Search