Absolute Java (6th Edition)
Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 17, Problem 3PP

Design and code a Swing GUI calculator. You can use Display 17.19 as a starting point, but your calculator will be more sophisticated. Your calculator will have two text fields that the user cannot change: One labeled "Result" will contain the result of performing the operation, and the other labeled "Operand" will be for the user to enter a number to be added, subtracted, and so forth from the result. The user enters the number for the "Operand" text field by clicking buttons labeled with the digits o through 9 and a decimal point, just as in a real calculator. Allow the operations of addition, subtraction, multiplication, and division. Use a GridLayout manager to produce a button pad that looks similar to the keyboard on a real calculator.

When the user clicks a button for an operation, the following occurs: the operation is performed, the "Result" text field is updated, and the "Operand" text field is cleared. Include a button labeled "Reset" that resets the "Result" to 0.0. Also include a button labeled "Clear" that resets the "Operand" text field so it is blank.

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.0 e 10 to + 1.0 e 10 .

Blurred answer
Students have asked these similar questions
MFC  In the second part of your project, you need to develop a mathematical worksheet graphical interface for elementary school students. The worksheet consists of 10 questions of operations between two random numbers. The operations are defined randomly from the set {+, -, *, /}. The GUI uses a text field to enter the maximum value of random numbers. A button with the caption "Check Answers" should be added to the GUI, and when clicked, a correct icon () should appear in front of the correct answer and an incorrect icon
Design and implement an application that presents three buttons and a label to the user. The buttons should be labeled Increment, Decrement, and Randomize. Display a numeric value (initially 50) using the label. Each time the Increment button is pushed, increment the value displayed. Likewise, each time the Decrement button is pushed, decrement the value displayed. When the Randomize button is pushed, the number displayed should be randomized between 1 and 100, inclusive.
value, which should then be output to the Fahrenheit field. • The second button should perform the inverse function. Be sure to use the field names provided in the comments in your starter code. An example of the program is shown below: Celsius 0.0 >>>> Temperature Converter Fahrenheit 32.0 <<<<

Chapter 17 Solutions

Absolute Java (6th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Gst = 75 GPa.

Mechanics of Materials (10th Edition)

Show that for circular motion, force = mass * velocity squared/radius.

Thinking Like an Engineer: An Active Learning Approach (4th Edition)

When a class variable is said to reference an object, what is actually stored in the class variable?

Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Time Complexity Analysis - How To Calculate Running Time | InterviewBit; Author: InterviewBit;https://www.youtube.com/watch?v=--oxG4Q1PA0;License: Standard YouTube License, CC-BY