I tried C++ and

Can anybody tell me what is wrong with this? I am losing my mind over this

#include
using namespace std;

int main()
{
int response, answer;
bool isMan;
bool isTall;

cout << "Are you male? (Y/N)" << endl;
    cin >> response;
    if (response =="Y") {
        cout << "You are a man";
        bool isMan = true
    }if (response =="N"){
            cout << "You are not a man";
            bool isMan = false
        }else {
            cout << "Error, you can only use Y or N to answer this question."
                break 0
        }

        cout << "Are you tall? (Y/N) << endl;
            cin >> answer

            if (answer =="Y") {
                cout << "You are tall";
                bool isTall = true
            }if (answer =="N") {
                    cout << "You are not tall";
                    bool isTall = false
                }






        if (isMan && isTall ) {
            cout << "You are a tall man" << endl;
            cout << "Can I get your number?";
        }if (isMan) {
            cout << "You are a short man";
        }if (isTall) {
            cout << "You are a tall woman";

        }
        else {
            cout << "You are a short woman";
        }

return 0

2 Likes

Are you getting a particular error?

1 Like

I fixed it

#include
#include “Proba.h”
using namespace std;

int main()
{
int response, answer;
bool isMan{};
bool isTall{};

cout << "Are you male? (Y/N)" << endl;
cin >> response;
if (response == 'Y') {
    cout << "You are a man";
    bool isMan = true;
}if (response == 'N') {
    cout << "You are not a man";
    bool isMan = false;
}
else {
    cout << "Error, you can only use Y or N to answer this question.";
}

cout << "Are you tall? (Y/N)"<< endl;
cin >> answer;

if (answer == 'Y') {
    cout << "You are tall";
    bool isTall = true;
}if (answer == 'N') {
        cout << "You are not tall";
        bool isTall = false;
    }


    if (isMan && isTall) {
        cout << "You are a tall man" << endl;
        cout << "Can I get your number?";
    }if (isMan && !isTall) {
        cout << "You are a short man";
    }if (isTall && !isMan) {
        cout << "You are a tall woman";

    }if (!isMan && !isTall) {
        cout << "You are a short woman";
    }
    else {
        cout << "Error";
    }

    return 0;

}

And now there is NO error, but when I try debbuging it, well it asks if you’re male or not, then when you answer Y you can’t move on to the next question and if you press enter the error message appears as if you wrote in something you weren’t supposed to … I see now instead of int I should probably use the answer and reposne as chars, but I’m not sure if that will help me either

3 Likes

How’s this going @LunaticLeviTheSecond?

1 Like

Oh yeah, this was so long ago I already forgot about it. So basically I deleted the bools and it worked fine. I think everything else was left the same.

2 Likes

Yay! Should I close this? :eyes:

1 Like

I just don’t understand why it wouldn’t work with bool commands … But sure, close it.

2 Likes

I think you’re missing ; at the end of the commands, but I’m not sure if you need that for booleans

1 Like

no I made sure to put ; on the end of each command, as you can see

1 Like

I think I know what the issue might be, if it’s not N, then it moves on to else and gives you an error. Try formatting it as
If ()
Else if ()
Else if ()
…etc.
Else

But I’m not entirely sure

1 Like

what would be the second Else if?

2 Likes

It depends, that was just an example. After the first if, put else before the next if, keep doing that until you reach else

Make sense?

2 Likes

No, becuase that would leave to the same conclusion I did

2 Likes

Hmm, well I’m all out of ideas

2 Likes

It doesn’t matter anymore, it’s solved by not solving it and doing it another way

2 Likes

sounds like programming :joy:

2 Likes

Closed due to inactivity.