/* Write a program that displays a menu which allows the user to move one unit north, east, south or west. Each time the player enters a selection, update the coordinates of the user and output the current position. Start the player at the origin of the coordinate system. Your programâ€™s output should look like the following: */ #include #include using namespace std; int main() { char cUserInput; int x; int i; int nPos[4][2]= // Represents positions or coordenates { {0,0}, //N {0,1}, //E {1,0}, //W {1,1} //S }; //Ask user for input for(i=0; i >=0; ++i) { cout << "Move (N)orth, (S)outh, (W)est, (E)ast, (Q)uit? "; cout << endl; cin >> cUserInput; switch(cUserInput) // Assign a value to X in order to make decisions. { case ("n"||"N"): x = 0; break; case ("e"||"E"): x = 1; break; case ("w"||"W"): x = 2; break; case ("s"||"S"): x = 3; break; case ("q"||"Q"): x = 4; break; default: x = 5; break; } if (x = 4){ //desicions based on X value cout << "Exiting...."; break; } else if(x > 4){ cout<< "Please insert a valid position"; continue; } else { cout << "Current position: ("; for(i=0; i <2; ++i){ cout << nPos[x][i]; cout << ","; } cout << ")" cout << endl; continue; } } }
Computer Science
• Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Looking for something else?

Not the answer you are looking for? Search for more explanations.