Write an applet that provides a windowing interface to let a user enter two resistor values and choose which configuration to calculate. Include two text fields (label them Resistor 1 and Resistor 2) for the two input values, two buttons (label them Series and Parallel) to select the configuration, and another text field (label it Equivalent Resistance) to display the calculated value and indicate which configuration was selected. For example, if the user enters 100 for R1 and 50 for R2 and clicks the Series button, the message would read Series Equivalent = 150. If the user enters the same values and clicks the Parallel button, the message would read Parallel Equivalent = 33.3. Put the applet in a Web page that explains the calculations.
Every first-year electrical engineering student learns that two resistors (a resistor is a common type of electrical component) can be connected in either of two configurations— series or parallel—and that there are simple formulas to calculate the equivalent resistance of a single resistor that could replace the two. If R1 and R2 are the two resistor values, then
Series resistance = R1 + R2, and
Parallel resistance = (R1 * R2) / (R1 + R2).
The applet can be created by copying code for any of the previously developed GUIs and may have any number of equally useful layouts. The solution shown here uses a five-row grid layout and two buttons, one to perform the calculations and another to clear all the text fields. The solution also tests for a variety of error conditions (e.g., no value entered for either or both resistors) and prints an appropriate message if the calculation cannot be performed.
See the code in ResistanceCalculatorAppet.java and ResistanceCalculator.html.
You might also like to view...
What is a DFS useful for in a graph?
a. To find cycles in a graph b. To find the minimum edge weight in a graph c. To find the maximal edge by weight in a graph d. To find the longest path between two vertices
In the accompanying figure, Item 1 points to the ____ button.
A. Demote B. Collapse C. Promote D. Expand
___________ is a bundled OS X application used for backing up and restoring a Mac
A) Backup B. iCloud Drive C. Time Machine D. Disk Utility
Which of the following is NOT a true statement that Divya can read about computer graphics?
Divya wants to learn as much as she can about computer graphics, so she can be prepared to make the best possible use of the tools that Flash offers for the manipulation of graphics. She also wants to know what Flash’s limitations are in terms of graphics. a. Logos, line drawings, or artwork with large areas of flat nongradient color are good choices for vector graphics. b. The bitmap format is an excellent choice for photos. c. Enlarged vectors remain sharp, clean, and in focus. d. A bitmap graphic is created with curves and points based on a mathematical formula.