Question: in c + + Goal: Use a do - while loop to perform actions. Assignment: Imagine you are programming a simulation for a robot that

in c++
Goal: Use a do-while loop to perform actions.
Assignment: Imagine you are programming a simulation for a robot that explores difficult areas to reach for humans. To chart paths for humans to follow, you need to know the overall distance traveled by the robot. The robot is designed so to report the total length it traveled in a straight path before rotating.
Task: Given the int variable totalDistance that has been declared and initialized, write some code that reads as input the distance traveled by the robot at each rotation and assigns to totalDistance the total distance the robot has traveled. The robot sends a 0 when it has finished moving. Assume the robot will always report positive integers or 0.
At the end, print out the total distance in the format Distance traveled: .
Note: You will need to write the lines of code to calculate the total distance and display them on the screen.

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 Programming Questions!