Results 1 to 3 of 3

Thread: Help - I need to make a calculator

  1. #1
    Senior Member
    Join Date
    May 2001

    Help - I need to make a calculator

    This is for a final project for my Java class. I've made the GUI and have no problems there, and I can tell what button was clicked.

    What I need help with is the process for determining what happens after a click. For example, if it is the first click, a - would start a negative number, but if it is the second (or later) click, it would store the current number and then start a subtraction process. Or, after entering a number, a function (add or whatever) and a second number and press =, you get a result. But then, if you enter a function (add, etc.) then you use result as the first number in your next equation. But, if you enter a number at that point, it should clear display and allow you to enter a number, etc.

    So... has anyone written a calculator in *any* language? I have enough experience with enough languages to be able to read most source, so if you have something that can let me see the process, I'd appreciate it.

  2. #2

    Re: Help - I need to make a calculator

    It just so happens I'm making a calculator for Visual Basic class. (Don't laugh. There's only two programming classes available at my college.) I don't have the source with me though to show you. But I'll try to explain it. I'm making an RPN calculator. I have a boolean variable called reset. Whenever the user clicks a number, if reset is true or the display is "0", then the display changes to that number. In other cases, the number is appended to the display. Any time a number is pressed, reset is cleared. Whenever a function or enter is pressed, reset is set. I figure you can do basically the same thing with a standard calculator. If you want to do it like a TI, I can't help you.

  3. #3

    Re: Help - I need to make a calculator

    It all depends how complicated you want it. Just remember that (-4) is (0-4), so theres no need to take a special case (as 0 is in the display, press "-" then "4" and you get (0-4) which is "-4".

Similar Threads

    By in forum Linux - General Topics
    Replies: 15
    Last Post: 11-21-2004, 10:02 AM
  2. What is the best graphing calculator??
    By in forum General Chat
    Replies: 3
    Last Post: 11-08-2003, 07:55 PM
  3. small C++ calculator!!
    By dox in forum Linux - Software, Applications & Programming
    Replies: 17
    Last Post: 10-16-2003, 11:35 PM
  4. This'll make you laugh (or cry)
    By SwampDonkey in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 10-24-2002, 09:02 PM
  5. How to make .so's with g++?
    By GotAnyGrapes? in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 07-22-2002, 09:15 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts