//nest3.cpp, nested ifs, checking for valid data #include using namespace std; int main() { int temp; bool warm; char ans; bool weekend; bool validData; cout << "What is the temperature? "; cin >> temp; warm = (temp > 70); cout << "Is it a weekend (y/n): "; cin >> ans; weekend = ((ans=='y') || (ans=='Y')); validData = (((ans=='y') || (ans=='Y') || (ans=='n') || (ans=='N')) && ((temp > 0) && (temp < 100))); if (validData) { if (weekend) { cout << "wear black dress." << endl; } else { if (warm) cout << "Wear t-shirt."<< endl; else cout << "Wear sweater" << endl; } } else cout << "Bad data" << endl; return 0; }