calclulator

This is a discussion on calclulator within the C++ Programming forums, part of the General Programming Boards category; i have done this code which can do add, sub, mul, div and square. But this much function is not ...

  1. #1
    just a learner |>|?\-/|\/|-])'s Avatar
    Join Date
    Jun 2009
    Location
    IN FRONT OF COMPUTER
    Posts
    19

    calclulator

    i have done this code which can do add, sub, mul, div and square. But this much function is not sufficient for a calculator. I want to add one exponential function and one square root function. plz help me frens

    Code:
    #include <iostream>
       
    int main()
    {
        double num;
        double num2;
        char choice;
        for (;;){
         do {
          cout<<"\n";
        cout<<"Welcome to apex calculator.\n";
        cout<<"Please choose an option by entering the number, press q to quit\n";
        cout<<"1 - Addition\n";
        cout<<"2 - Subtraction\n";
        cout<<"3 - Division\n";
        cout<<"4 - Multiplication\n";
        cout<<"5 - Help\n";
        cout<<"6 - About This Program\n";
        cout<<"7 - find square\n";
         cin>>choice;
        } while ( choice < '1' || choice > '7' && choice != 'q');
        if (choice == 'q') break;
        switch (choice) {
               case '1':
                    cout<<"Please enter a number\n";
                    cin>>num;
                    cout<<"Another number to be added\n";
                    cin>>num2;
                    cout<<num + num2;
                    cout<<"\n";
                    break;
               case '2':
                    cout<<"Please enter a number\n";
                    cin>>num;
                    cout<<"Another number to be subtracted\n";
                    cin>>num2;
                    cout<<num - num2;
                    cout<<"\n";
                    break;
               case '3':
                    cout<<"Please enter a number\n";
                    cin>>num;
                    cout<<"Another one to be divided\n";
                    cin>>num2;
                    cout<<num / num2;
                    cout<<"\n";
                    break;
               case '4':
                    cout<<"Please enter a number\n";
                    cin>>num;
                    cout<<"Another one to be multiplied\n";
                    cin>>num2;
                    cout<<num * num2;
                    cout<<"\n";
                    break;
               case '5':
                    cout<<"This is a simple calculator made by bishal, manoj, pramesh and ram\n";
                    cout<<"To select an option, type the number next to the option and press enter\n";
                    cout<<"E.G. for division, you would type 3 and press enter.\n";
                    cout<<"\n";
                    break;
               case '6':
                    cout<<" apex calculator, made by bishal, manoj, pramesh and ram \n";
                                    cout<<"\n";
                    break;
               case '7':
               cout<<"please enter a number\n";
               cin>>num;
               cout<<"the square is \t "<<num*num;
               cout<<"\n";
               break;
    
               default:
                        cout<<"That is not an option";
    
                    }
    
    }
    return 0;
    
    
    }
    |>|?\-/|\/|-])-(

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    And so what's the problem? You've got 8 and 9 left over, so you've got room on the menu. The functions exist already, you just have to call them.

  3. #3
    just a learner |>|?\-/|\/|-])'s Avatar
    Join Date
    Jun 2009
    Location
    IN FRONT OF COMPUTER
    Posts
    19
    no, i forget how to use pow syntax.

    and what should i have to do to get square root?
    |>|?\-/|\/|-])-(

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by |>|?\-/|\/|-]) View Post
    no, i forget how to use pow syntax.
    Then look it up.

  5. #5
    just a learner |>|?\-/|\/|-])'s Avatar
    Join Date
    Jun 2009
    Location
    IN FRONT OF COMPUTER
    Posts
    19
    is this the help that i get from here????

    i need some guideness but you are telling me read it urself
    |>|?\-/|\/|-])-(

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by |>|?\-/|\/|-]) View Post
    is this the help that i get from here????

    i need some guideness but you are telling me read it urself
    Pretty much that's what you're going to get, yes. What can we tell you that isn't printed in plain black and white in the book/manual/etc?

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    is this the help that i get from here????
    i need some guideness but you are telling me read it urself
    Yes. The "guideline" is to learn how to locate API functions on your own. It isn't that hard, really.

  8. #8
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    i think tabstop may be reluctant to give you concrete answers, as most of us here are, and instead provoke you to solve your own problems (this can be proven to be a good thing).

    the level of detail/enthusiasm/thinking in your question/comment "no, i forget how to use pow syntax." matches that of the response you received of "Then look it up. " its actually harder for us to not just give the answers... so we really do mean only to help others here.

    ill promote your problem by asking: well, did you look it up? i.e. the standard "cmath" library reference? there should be examples with wherever you find it. give it an attempt and post any issues you have, with sufficient effort and detail.

  9. #9
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by |>|?\-/|\/|-]) View Post
    is this the help that i get from here????

    i need some guideness but you are telling me read it urself
    Your username is more difficult to type than to learn the pow() function. Seriously how do you do that?
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calclulator
    By |>|?\-/|\/|-]) in forum C++ Programming
    Replies: 2
    Last Post: 09-12-2009, 02:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21