bartleby

Videos

Question
Book Icon
Chapter 9, Problem 7PP
Program Plan Intro

Calculator program

Program Plan:

Filename: “Calculator.java”

  • Import the required packages.
  • Declare the class “Calculator”.
    • Declare the required variables.
    • Define the “init” method.
      • Declare the required variables for “JFrame”.
      • Create an object for “Container” class.
      • Create the objects for “JPanel”.
      • Create a label.
      • Create a text field.
      • Add the labels on the window.
      • Create a label.
      • Create a text field.
      • Add the labels on the window.
      • Create the buttons.
      • Add the action to these buttons.
      • Add the action to the buttons.
      • Add the buttons on the window.
      • Add the labels.
      • Set the layout.
      • Add the labels on the window.
      • Add the buttons on the window screen.
      • Add the label on the window screen.
    • Declare the “actionPerformed” method.
      • Declare the string variable.
      • In the “try” block,
        • Check the action command is equal to “Update”, call the “doCalculation” method otherwise set the text “Reset” and call the “reset” method.
        • Set the string value into “resultString” variable.
        • If the “resultString” length is greater than 15, divide the string and assign the value to the variable.
        • Set the text.
          • In the “catch” block, “UnknownOpException” exception is thrown.
          • Another “catch” block thrown “DivideByZeroException” exception.
    • Define the “reset” method.
      • Set the value as “0.0”.
    • Define the “doCalculation” method.
      • Declare the required variables.
      • Get the character position and assign it into the variable.
      • Get the substring and assign it into the variable.
      • Convert the value into double and assign it into the variable.
      • Call the method “evaluate”.
    • Define the “evaluate” method.
      • Declare the variable.
      • The “switch-case” is used to do the arithmetic operation.
      • Return the result.

Blurred answer
Students have asked these similar questions
Use a simple exponential smoothing Method to forecast one-quarter-ahead revenues for Home Depot. Refer to the Home Depot Quarterly.xlsx dataset Year and Quarter Homedepot sales 19811 8.010999978 19812 10.60699999 19813 13.71499997 19814 19.20899999 19821 25.60999996 19822 33.06299996 19823 28.727 19824 30.24599999 19831 42.99299991 19832 66.61299992 19833 64.08299995 19834 82.49499989 19841 95.87199998 19842 119.0679998 19843 100.4589999 19844 117.3799999 19851 145.0479999 19852 174.2389998 19853 177.7179999 19854 203.724 19861 222.619 19862 263.4329996 19863 251.5369997 19864 273.8729992 19871 333.9689999 19872 381.4429998 19873 364.2449999 19874 374 19881 446.5919991 19882 518.1589985 19883 509.9899998 19884 524.7729988 19891 641.5209999 19892 704.0249996 19893 699.7399998 19894 713.2489986 19901 880.855999 19902 990.3459988 19903 936.6119995 19904 1007.542 19911 1186.889999 19912 1352.792 19913…
Write the set of SQL commands necessary to insert the data into the INVOICE table you created in Problem 17, as illustrated in Figure P8.16.
Refer to the shampoo_sales.xlsx time-series dataset. This data shows sales of shampoo over three years monthly. Carry out simple exponential smoothing and Holt's Trend-Corrected on this data and determine whether the data shows any trend. Assume the initial value for the level smoothing parameter (alpha) and Trend smoothing parameter (gamma) is 0.5 Month Sales of shampoo over a three year period 1-Jan 266 1-Feb 145.9 1-Mar 183.1 1-Apr 119.3 1-May 180.3 1-Jun 168.5 1-Jul 231.8 1-Aug 224.5 1-Sep 192.8 1-Oct 122.9 1-Nov 336.5 1-Dec 185.9 2-Jan 194.3 2-Feb 149.5 2-Mar 210.1 2-Apr 273.3 2-May 191.4 2-Jun 287 2-Jul 226 2-Aug 303.6 2-Sep 289.9 2-Oct 421.6 2-Nov 264.5 2-Dec 342.3 3-Jan 339.7 3-Feb 440.4 3-Mar 315.9 3-Apr 439.3 3-May 401.3 3-Jun 437.4 3-Jul 575.5 3-Aug 407.6 3-Sep 682 3-Oct 475.3 3-Nov 581.3 3-Dec 646.9

Chapter 9 Solutions

Java: An Introduction to Problem Solving and Programming plus MyProgrammingLab with Pearson eText -- Access Card Package (7th Edition)

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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License