Skip to main content

Java Calculator (Basic)

7 replies [Last post]
shanezz
Offline
Joined: 2007-04-29
Points: 0

Hi can anyone help me on this i have to do a basic calculator with Java that contain two integer fields and an array,results. It should be capable of adding 2 numbers, subtracting 2 numbers, dividing 2 numbers, and multiplying 2 numbers, and giving the remainder after division of the two integer numbers, any help would be greatly appreciated, thank you.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mukesh11
Offline
Joined: 2009-04-05
Points: 0

This applet accomplishes a couple of different things: obviously, it is an example of a calculator, but also displays an example of how to multithread an applet. The Time Used display on the left-hand side near the bottom is a thread ran from within the applet itself.

The Current Time display on the right-hand side near the bottom is a thread that was declared in class called "Clock" which extended Thread. It is instantiated within the applet and the overridden run method inside of the Clock class obtains the current time for display.

The calculator itself has been set up to handle keyboard events, but as far as the program is concerned the focus must be on the applet in general -- the keystrokes won't work otherwise. To do this, click on any empty area of the applet.
------------
mukesh11
[url=http://www.currencyconverter247.com]Currency Converter[/url] - Currency Converter

rickcarson
Offline
Joined: 2004-03-04
Points: 0

Apple's section for developers has half a dozen different currency converter examples, which is similar to the calculator you describe. I think one of the Objective-C books has a calculator that it builds up as an example as well.

The 'trick' with a calculator is to keep some kind of rolling total.

ewin
Offline
Joined: 2005-07-15
Points: 0

A fundamental idea of homework is that one does his own. That is, you, not we, do your homework.

And to all the ones who want to be helpful, consider this. Imagine you become a professional developer. Do you want to work with colleagues who got their programming credentials by letting others do their homework? Do you want to have to do their work in addition to your own, because they are used to others doing their work and can't deliver?

jmguillemette
Offline
Joined: 2003-06-11
Points: 0

Most developers get annoyed by people asking for help.. we are very much in a solve it your self mentality.

i however will gladly help a person.. assuming they in turn do the work.. i can guide and teach.. NOT do.

For exactly the reason mentioned above

coxcu
Offline
Joined: 2003-06-11
Points: 0

Here's an interesting, if dated, article that uses development of a calculator as an example.

"XP Testing a GUI with FIT, Fitnesse, and Abbot"
http://www.csis.pace.edu/~bergin/xp/guitesting.html

jmguillemette
Offline
Joined: 2003-06-11
Points: 0

ill help you .. but i would need you to post up what you have written so far.. and a description of the problem your running into :)

mwithake
Offline
Joined: 2006-02-08
Points: 0

homework?