Results 1 to 3 of 3
  1. #1
    Snoozer's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    8
    Reputation
    10
    Thanks
    0
    My Mood
    Bored

    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;
    }

  2. #2
    lalakijilp's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Posts
    310
    Reputation
    9
    Thanks
    53
    My Mood
    Blah
    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.

  3. The Following User Says Thank You to lalakijilp For This Useful Post:

    Snoozer (01-27-2010)

  4. #3
    Threadstarter
    Unverified User
    Snoozer's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    8
    Reputation
    10
    Thanks
    0
    My Mood
    Bored
    Ah.. i see, thanx. xD

    And btw, thanx for the tip, will do ^^.

Similar Threads

  1. Hey guys..got problem here..
    By tpw1314 in forum Blackshot Hacks & Cheats
    Replies: 1
    Last Post: 07-27-2009, 05:38 AM
  2. Hey guys..got problem here..
    By tpw1314 in forum Blackshot Hacks & Cheats
    Replies: 0
    Last Post: 07-27-2009, 03:56 AM
  3. Guyz Got Problem !!
    By Kevinnqc in forum Combat Arms Hacks & Cheats
    Replies: 9
    Last Post: 09-12-2008, 10:53 AM
  4. Hey got problem
    By sungkwan11 in forum WarRock - International Hacks
    Replies: 1
    Last Post: 11-25-2007, 09:02 AM
  5. Yahoo slurp gots problems :S
    By Dave84311 in forum General
    Replies: 6
    Last Post: 10-24-2006, 08:18 PM