I am trying to get an if else statement within an if statement, but I keep getting this error on line 34 of my code. I think I am possibly having a problem with the placement of my brackets as im being told a '}' is expected before the inner else statement, but can't figure it out. Thanks for any help you may provide.
int main() {
string time, pressure, weather, feel;
cout<<"Welcome to the Go to Work or School Program!"<<endl;
cout<<"Did you wake up on time ? (Y/n)"<<endl;
cin>>time;
// outer if condition
if (time == "y" || "Y")
{
cout << "How is the water pressure?\n" << "A) Fine\n" << "B) Bad" << endl;
cin >> pressure;
// inner if condition
if (pressure == "a" || "A")
cout << "Is it snowy or rainy outside?\n" << "A) Nope\n" << "B) Yea" << endl;
cin >> weather;
// inner else condition
else
cout << "Call in sick" << endl;
}
// outer else condition
else
{
cout << "Call in sick" << endl;
}
return 0;
I added more brackets to the inner statements, but now the code within the else statements is unreachable
int main() {
string time, pressure, weather, feel;
cout<<"Welcome to the Go to Work or School Program!"<<endl;
cout<<"Did you wake up on time ? (Y/n)"<<endl;
cin>>time;
// outer if condition
if (time == "y" || "Y")
{
cout << "How is the water pressure?\n" << "A) Fine\n" << "B) Bad" << endl;
cin >> pressure;
// inner if condition
if (pressure == "a" || "A")
{
cout << "Is it snowy or rainy outside?\n" << "A) Nope\n" << "B) Yea" << endl;
cin >> weather;
}
// inner else condition
else
{
cout << "Call in sick" << endl;
}
}
else
{
cout << "Call in sick" << endl;
}
return 0;