#include #include using namespace std; int main() { srand( time( 0 ) ); // randomize int n = rand() % 4; // 0-3 n++; // 1-4 // the if-else chain using the == operator // and one variable (i.e. n) if ( n == 1 ) { cout << "You'll have a nice day.\n"; } else if ( n == 2 ) { cout << "Stay inside today.\n"; } else if ( n == 3 ) { cout << "Call your parents.\n"; } else if ( n == 4 ) { cout << "You'll lose all your money today.\n"; } else { cout << "Something's wrong.\n"; } // switch statement: switch ( n ) { case 1: // <== combine cases 1 and 2 case 2: cout << "You'll have a nice day.\n"; break; case 3: cout << "Call your parents.\n"; break; case 4: cout << "You'll lose all your money today.\n"; break; default: cout << "Something's wrong.\n"; break; } return 0; }