I gots problem QQ

Posts 1–3 of 3 · Page 1 of 1
I gots problem QQ
Hai all ;o

I tried to make an calculator just like the one that was already posted in this section.. Tried to improve it, by adding a confirmation thingy, and later on things like 6^2=36 etc etc..
(I'm not a copy/paste fag, i retyped it in my own style for educational purposes.. gosh i sound smart x_x)

But the problem is, I can't use the multiply function or divide function so far.
When i try to use the multiply/divide function it openens the subtract function..

Here's the code;


Code:
#include <iostream>
#include <string>

using namespace std; 

int main()
{
    float a;
    float b;
          float s;
    string choice;
    string cont;
    string zchoice;
    
    cout << "\nHello peoplez.\nMy name is Snoozer's Calculator V1.\n";
    cout << "So, How can i help you today?\n\nType \"A\" for Add.";
    cout << "\nType \"S\" for Subtract.\nType \"M\" for Multiply\n";
    cout << "And as last, type \"D\" for Divide\n";
    cin >> choice;
    
    if (choice == "A")
    {
               cout << "\nYou chose Add, is this correct? Type: Yes/No\n";
               cin >> zchoice;
               
               if (zchoice == "No")
               {
                           main ();
               }
               
               else (zchoice == "Yes");
               {
                    cout << "\nOk good!\nPlease type in the first number:\n";
                    cin >> a;
                    cout << "Now type the second number:\n";
                    cin >> b;
                    cout << "    " << a << " + " << b << " = " << a+b << endl;
                    cout << "\n";
                    cout << "Would you like to continue? Type: Yes/No\n";
                    cin >> cont;
                             if (cont == "Yes")
                             {
                                    main ();
                             }
                    
                               else (cont == "No");
                               {
                               return 0;
                               }
               }
    }


    if (choice == "S");
    {
               cout << "\nYou chose Subtract, is this correct? Type: Yes/No\n";
               cin >> zchoice;
               
               if (zchoice == "No")
               {
                           main ();
               }
               
               else (zchoice == "Yes");
               {
                    cout << "\nOk good!\nPlease type in the first number:\n";
                    cin >> a;
                    cout << "Now type the second number:\n";
                    cin >> b;
                    cout << "    " << a << " - " << b << " = " << a-b << endl;
                    cout << "\n";
                    cout << "Would you like to continue? Type: Yes/No\n";
                    cin >> cont;
                             if (cont == "Yes")
                             {
                                    main ();
                             }
                    
                               else (cont == "No");
                               {
                               return 0;
                               }
               }
    }


    if (choice == "M")
    {
               cout << "\nYou chose Multiply, is this correct? Type: Yes/No\n";
               cin >> zchoice;
               
               if (zchoice == "No")
               {
                           main ();
               }
               
               else (zchoice == "Yes");
               {
                    cout << "\nOk good!\nPlease type in the first number:\n";
                    cin >> a;
                    cout << "Now type the second number:\n";
                    cin >> b;
                    cout << "    " << a << " * " << b << " = " << a*b << endl;
                    cout << "\n";
                    cout << "Would you like to continue? Type: Yes/No\n";
                    cin >> cont;
                             if (cont == "Yes")
                             {
                                    main ();
                             }
                    
                               else (cont == "No");
                               {
                               return 0;
                               }
               }
    }


    if (choice == "D")
    {
               cout << "\nYou chose Divine, is this correct? Type: Yes/No\n";
               cin >> zchoice;
               
               if (zchoice == "No")
               {
                           main ();
               }
               
               else (zchoice == "Yes");
               {
                    cout << "\nOk good!\nPlease type in the first number:\n";
                    cin >> a;
                    cout << "Now type the second number:\n";
                    cin >> b;
                    cout << "    " << a << " / " << b << " = " << a/b << endl;
                    cout << "\n";
                    cout << "Would you like to continue? Type: Yes/No\n";
                    cin >> cont;
                             if (cont == "Yes")
                             {
                                    main ();
                             }
                    
                               else (cont == "No");
                               {
                               return 0;
                               }
               }
    }

char f;
cin >> f;
return 0;
}
Code:
    if (choice == "S"); //remove the ;
it took me a while but I found it...

if you really want to improve the calculator code-wise google switch and functions so you can make it easier to read and to change.
Ah.. i see, thanx. xD

And btw, thanx for the tip, will do ^^.
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us