Question: (C++) You MUST use for loop to complete this exercise. In this program, you will stimulate the movement of a robot on a plane. The

(C++) You MUST use for loop to complete this exercise. In this program, you will stimulate the movement of a robot on a plane. The robot ALWAYS starts at position (0,0) and must reach (4,4) in 10 steps. At each iteration, the user enters one of the following options: up, down, left, right.

(C++) You MUST use for loop to complete this exercise. In this

WARNING: You MUST use for loop to complete this exercise to receive points! In this program, you will simulate the movement of a robot on a plane. The robot ALWAYS starts at position (0,0) and must reach (4,4) in 10 steps. At each iteration the user enters one of the following options: up, down, left, right, up increases y coordinate by 1. For example, the robot would go from (0,0) to (0.1) down decreases y coordinate by 1. For example, the robot would go from (0,0) to (0-1) right increases x coordinate by 1. For example, the robot would go from (0,0) to (1,0) left decreases x coordinate by 1. For example, the robot would go from (0,0) to (-1,0) After 10 iterations, print the final coordinates in the format (x,y). And the message The robot reached the destination! if the final coordinates are (44), or The robot did not reach the destination! otherwise. Note that it does not matter if the robot passes through (4,4) during its movement. It has to be its final position Hint: Use two integer variables to store the x and y positions of the robot, starting from (0,0) and being updated each iteration. During each iteration, use a string variable to receive the user input of 'up', 'down", "right" or "left, and based on the input, update the x and y positions of the robot

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!