Gui controls memory calculator

Assignment Help JAVA Programming
Reference no: EM131578982

GUI Controls Memory Calculator

This is the last homework assignment in this course, and it is meant to show you how a small but complete GUI application is structured. We will make our GUI actually control our memory calculator.

To do this, you will need to create an instance of MemoryCalc in the CalcGUI and write event Handlers to pass information back and forth between the calculator and the GUI. There are many possible ways to achieve this, but the easiest is probably to develop four different event Handlers:

DigitHandler - This event Handler is added to the 0-9 and . (dot) keys. If the equals button was just pressed, this event Handler will overwrite the total shown in the text field with the value of the key (its label) that was just pressed. If the equals button was not just pressed, this event Handler will append the current key's label onto the end of the string shown in the text field.

OperatorHandler - This event Handler is added to the +, -, *, and / keys. It sets the value of a class field to the operator that the user has chosen.

ClearHandler - This event Handler is added to the C key. It calls the calculator's clear method and sets the value of the text field back to 0.0.

EqualsHandler - This event Handler is added to the = key. It reads the current value from the text field, converts it to a double, and calls the appropriate calculator method based on the current operator, passing in the double value. The calculator will compute the answer, and then this event Handler will update the value in the text field to the calculator's current total.

That is all that required for the homework assignment, however I also encourage you to play around with the different types of calculators we have written in this course, perhaps after this course ends. For instance, you could add functionality for geometric operations like sine and cosine. Or you could create a Super Calculator that has different views for scalar, vector, and matrix calculations. Whatever you come up with, I suggest you clean it up and document it. Potential employers always look favorably on being able to review code you have written and ask you questions about it.

Hints:

You can use the ActionEvent's getSource() method to get a reference to the button that was pressed, and you can use Button's getText() method to find out the label of that button.

When the EqualsHandler is converting the text shown in the text field into a double value in order to pass it to the calculator, be careful to handle the case where the text field contains an invalid value, such as 6..72. In this case you should catch the exception, display an error message to the user, and abort the call to the calculator (just restore the current total to the text field).

The user should only be able to enter numbers between when an operator has been selected and when the equals button has been pushed. The DigitHandler should ignore any button presses when the GUI is not in this state.

Reference no: EM131578982

Questions Cloud

Is client stigmatized because of health problems : Is client stigmatized because of health problems? Does the clients' health problem affect his/her social and economic role in society?
What constitutes the necessary quality for the project : Which definition of quality "wins"? What steps can you take to ensure you and the customer agree on what constitutes the necessary quality for the project?
Analyze the manner in which his actions rose : Jack Kevorkian's saying, "dying is not a crime", and analyze the manner in which his actions rose to the level of homicide
Prepare current assets section of yasunari kawabata company : Prepare the current assets section of Yasunari Kawabata Company's December 31, 2017, balance sheet, with appropriate disclosures
Gui controls memory calculator : create an instance of MemoryCalc in the CalcGUI and write event Handlers to pass information back and forth between the calculator and the GUI
Explore the management of human capital in the organization : Briefly explore the management of human capital in the organization. Describe three employment laws and the consequences of non-compliance.
Explain functional alcoholism : Explain Functional Alcoholism and DUI Offense Basics
Describe briefly the health concern you chose : Explain how lifestyle choices and behaviors play a role in this health care concern. Are they significant contributors to this issue?
What is the dividend yield for com-usa : This is expected to continue indefinitely. The company just paid a dividend of $2.00 per share and its stock is selling at $46.00 per share.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd