-1

When I run the code, it works till the part where it asks about the dog's bredd, I press enter and it asks me about the dog's name, that's not supposed to appear. And also, when I enter the weight and press enter nothing happen, it's supposed to give me an answer but I don't know what's going on!, help me please!
thanks

cout<<"First Name and Last Name: "<<endl;
    getline(cin,naME);


    cout<<"Do you own a dog at the present time? Type 1 for YES or 0 for NO: "<<endl;
    cin>>gotDog;

    if(gotDog){
        cout<<"What is the dog's breed?: "<<endl;
        cin.ignore(200, '\n');
        getline(cin,brEEd);

        if(brEEd == "pit-bull"){
            cout<<"You are not welcome to the condominium!"<<endl;
            cout<<"It's illegal to have a pit-bull in South Florida."<<endl;

        }else{
            cout<<"How much does it weight?: "<<endl; 
            cin.ignore(200, '\n');
            getline(cin,lbs);
        }

            if(lbs >= "30"){
                cout<<"You are not welcome to the condominium!"<<endl;
                cout<<"It's prohibited to have dogs that weights more then 30 lbs."<<endl;
            }else{
                cout<<"What is the dog's name? "<<endl;
                cin.ignore(200, '\n');
                getline(cin,dogNm);
            }
    }else{
        cout<<"You are welcome to the condominium!"<<endl;
    }

Edited by Dani: Formatting fixed

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by WaltP
0

Why don't you write that for getting input from the user:

string breed;
cin >> breed;

This method does not get the "\n".

0

Yes, be consistent with your input. Always use getline() and you shouldn't have to worry about cin.ignore()

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.