locked
Math Calculator using C# RRS feed

  • Question

  • I want to make a simple calculator (like the basic Windows calculator) that enables you to add, subtract, multiply and divide more than two variables at a time. At the moment, my application doesn't seem to do it. It only adds the last two numbers and therefore, these are how the following calculations get processed:
    2+2=4
    2+2+2=4
    2+2=4+2=6

    Is there any way that I can overcome this problem? I need it ASAP.
    Thanks for any help! :)


    NOTE: The programming language is C#
    Saturday, September 21, 2013 2:49 AM

Answers

  • Hi,

    There is a sample you can refer to,may be that can help you:

    http://www.c-sharpcorner.com/UploadFile/7e39ca/making-a-calculator-in-windows-store-apps/

    This sample work very well when subtract, multiply and divide more than two variables at a time.When you add more than two variables ,you should putting one variable in answer variable and then use answer variable inside Calculatetotals, so your code for add will be answer = answer + variable2. Now after second click add button, the last value will be repeatedly added to the last answer.May be you do not follow that,so  your project  only adds the last two numbers.

    Best Wishes!


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    • Edited by Anne Jing Tuesday, September 24, 2013 12:51 PM from
    • Marked as answer by Anne Jing Monday, September 30, 2013 2:00 AM
    Tuesday, September 24, 2013 12:51 PM

All replies

  • Hi 007,

    would it be possible to post your code? Else it's hard to say what your code doesn't do right.


    Thomas Claudius Huber

    "If you can´t make your app run faster, make it at least look & feel extremly fast"

    twitter: @thomasclaudiush
    homepage: www.thomasclaudiushuber.com
    author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook

    Saturday, September 21, 2013 9:10 AM
  • Hi,

    There is a sample you can refer to,may be that can help you:

    http://www.c-sharpcorner.com/UploadFile/7e39ca/making-a-calculator-in-windows-store-apps/

    This sample work very well when subtract, multiply and divide more than two variables at a time.When you add more than two variables ,you should putting one variable in answer variable and then use answer variable inside Calculatetotals, so your code for add will be answer = answer + variable2. Now after second click add button, the last value will be repeatedly added to the last answer.May be you do not follow that,so  your project  only adds the last two numbers.

    Best Wishes!


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    • Edited by Anne Jing Tuesday, September 24, 2013 12:51 PM from
    • Marked as answer by Anne Jing Monday, September 30, 2013 2:00 AM
    Tuesday, September 24, 2013 12:51 PM