Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with my calculator please!

    i've designed a basic calculator and its working but not how i want it to. i've designed it (and dont want to change the design) so when the the user is inputting their calculation it all displays on the screen e.g. 1+3*5, now when someone puts a calculation in like that it does 3*5 then adds the 1 but i want it so it does the 1+3 first then multiplies by 5.

    can anyone help?

    thanks

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    You must put the addition in brackets if you want to alter the normal order of precedence in calculations:-

    1+3*5 = 16 (multiplication is performed before addition)

    (1+3)+5 = 20 (brackets force addition to be performed first)


  •  

    Posting Permissions

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