| | |
nested if, else
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 22
Reputation:
Solved Threads: 0
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;
}
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;
}
![]() |
Similar Threads
- Program Help Using For Nested Loops (C++)
- nested for loop problem (Java)
- Nested For Loops (C++)
- program w/ switch AND nested if. six error messages (C++)
- query: allocating memory to nested linked lists (C)
- QBasic Nested for loop (Legacy and Other Languages)
- MySQL nested query / joined query conversion help (MySQL)
Other Threads in the C++ Forum
- Previous Thread: How to find largest/smallest position in a vector?
- Next Thread: File handling/database management
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct temperature template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






