Author Topic: please help me with if then statements  (Read 4066 times)

Offline Benneb10

  • Single posting newcomer
  • *
  • Posts: 2
please help me with if then statements
« on: February 08, 2017, 09:11:10 pm »
this is probably a simple fix, but I'm trying to use if-then statements to set up a calculator that asks what type of equation and all that, I spent a while on it and I'm tired, so this is probably a simple fix but here is the code

Code
#include <iostream>

using namespace std;

int main()
{
    float x;

    cout << "please enter 1 or 2: ";
    cin >> x;
    if ((x = 1)){
        float x;

        cout << "1please enter 0, 2, 3, or 4: ";
        cin >> x;
        {if ((x = 1)){
                cout << "Fix this ####, 1.0";//this is only here to let me know if i figured out the problem, and if i solved it.
            return 0;
            }
            else if ((x = 0)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 1.1";
            return 0;
            }
            else if ((x = 2)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 1.2";
            return 0;
            }
            else if ((x = 3)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 1.3";
            return 0;
            }
            else if ((x = 4)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 1.4";
            return 0;
            }
        }
    }
    else if ((x = 2)){
        float x;

        cout << "2please enter 1, 2, 3, or 4: ";
        cin >> x;
        {if ((x = 1)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 2.1";
            return 0;
            }
            else if ((x = 2)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 2.2";
            return 0;
            }
            else if ((x = 3)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 2.3";
            return 0;
            }
            else if ((x = 4)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 2.4";
            return 0;
            }
        }
    }
}
please help and I will be very gratefull.

PS. I can not spell, so any spelling errors please don't judge me for
PPS. I looked on Google, but I am bad at figuring out what to search, and so if it on google how to help, please just post the link and I will try to look at it and reply whether or not I figured it out.

Offline Benneb10

  • Single posting newcomer
  • *
  • Posts: 2
Re: please help me with if then statements
« Reply #1 on: February 08, 2017, 09:34:38 pm »
I have slightly modified the code, just some of the text

Code
#include <iostream>

using namespace std;

int main()
{
    float x;

    cout << "please enter 1 or 2: ";
    cin >> x;
    if ((x = 1)){
        float x;

        cout << "1please enter 0, 2, 3, or 4: ";
        cin >> x;
        {if ((x = 1)){
                cout << "Fix this ####, 1.0";
            return 0;
            }
            else if ((x = 0)){
                cout << "yay, your not a dumbass, x = 0, 1.1";
            return 0;
            }
            else if ((x = 2)){
                cout << "yay, your not a dumbass, x = 2, 1.2";
            return 0;
            }
            else if ((x = 3)){
                cout << "yay, your not a dumbass, x = 3, 1.3";
            return 0;
            }
            else if ((x = 4)){
                cout << "yay, your not a dumbass, x = 4, 1.4";
            return 0;
            }
        }
    }
    else if ((x = 2)){
        float x;

        cout << "2please enter 1, 2, 3, or 4: ";
        cin >> x;
        {if ((x = 1)){
                cout << "yay, your not a dumbass, x = 1, 2.1";
            return 0;
            }
            else if ((x = 2)){
                cout << "yay, your not a dumbass, x = 2, 2.2";
            return 0;
            }
            else if ((x = 3)){
                cout << "yay, your not a dumbass, x = 3, 2.3";
            return 0;
            }
            else if ((x = 4)){
                cout << "yay, your not a dumbass, x = 4, 2.4";
            return 0;
            }
        }
    }
}
« Last Edit: February 08, 2017, 09:39:17 pm by Benneb10 »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: please help me with if then statements
« Reply #2 on: February 08, 2017, 09:46:17 pm »
ok, i think i will rage quit now...

1) YOU agreed by signing in to this forum that you agree with the rules. There is cleaerly written that programming questions are not allowed at this forum... To neglect the rules will result in a ban. Your question is 100% programming related 0% codeblocks related

2) This is rhetoric: WHAT IS YOUR QUESTION....
 ..... just by looking at your code i see the obvious problem... but i don't see any concrete question in your post, what your problem is...

3) READ THE WARNINGS OF YOUR COMPILER. WARNINGS ARE THERE FOR A REASON....

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: please help me with if then statements
« Reply #3 on: February 08, 2017, 11:04:18 pm »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: please help me with if then statements
« Reply #4 on: February 09, 2017, 09:56:18 pm »
Topic locked, everything else is said by BlueHazzard and stahta01 .