File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes I need some calculation help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I need some calculation help" Watch "I need some calculation help" New topic

I need some calculation help

Stephenie Jannings

Joined: Apr 12, 2002
Posts: 1
I have an assignment to make a calculator. This has to be done on a BorderLayout with a panel set to GridLayout. All that has been accomplished; however, to get the results to calculate is causing me great pain.
This is the code that I have for the numbers to appear. I need to somehow get the number that will be inputted to add, subtract, multiply, and divide another number that will be inputted.
Any suggestions will greatly be appreciated. Thanks
expired user

Joined: Dec 13, 2001
Posts: 11
I have a code for calculator whic i designed. Try this code and check out if it helps you.

(edited by Cindy to format code)
[ April 14, 2002: Message edited by: Cindy Glass ]
Jake Westphal

Joined: Apr 10, 2002
Posts: 4
A note on OO design with regard to the code above, I read a good article about using inner classes to remove large switch or if/if else statements. It helped me understand good, real world uses for anonymous classes.
It would change the code above so that each button has its own implementation of actionPerformed, and thus, the large if/if statement in actionPerformed is not needed.
Here is the article:
Inner Classes
I agree. Here's the link:
subject: I need some calculation help
It's not a secret anymore!