Results 1 to 3 of 3

Thread: Help - I need to make a calculator

  1. #1
    Senior Member
    Join Date
    May 2001
    Posts
    472

    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

  1. How To Make A Dedicated File Server Or Web Server
    By beezlebubsbum in forum Linux - General Topics
    Replies: 11
    Last Post: 02-22-2009, 12:12 AM
  2. Need help installing gnu make 3.80.0(fixed)
    By AljoshaNL in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 08-19-2005, 11:51 AM
  3. How to make linux "FASTER"
    By comtux in forum Linux - General Topics
    Replies: 11
    Last Post: 01-27-2005, 10:04 PM
  4. Exerciser
    By garskoci in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 12-12-2001, 12:01 PM

Bookmarks

Posting Permissions

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