// Solution to Lab8, problem 1: #include int main() { // declare integer variables x and y. int x; int y; // prompt user, and take input for variable x. cout << "Enter an integer: "; cin >> x; // assign y to 2*x. y = 2*x; // if x is between -10 and +10, double the value of x (change x) // otherwise, (using a nested if statement), test if the value of // x is negative (< -10) or positive. If it's negative, set x to // to -10 and print a message "x has been set to -10", otherwise, set // x to 10 and print "x has been set to +10". if ( (x >= -10) && (x <= 10) ) { x = x*2; } else { if (x < 0) { x = -10; cout << "x has been set to -10"; } else { x = 10; cout << "x has been set to +10"; } // end of inner if-else } // end of outer if-else // Print out the final values of x and y, indicating which is which cout << "x == " << x << " and y == " << y << "\n"; return 0; }