Question: Assignment: Imagine you are programming a simulation for a robot that explores areas that are difficult for humans to reach. The robot periodically sends the
Assignment: Imagine you are programming a simulation for a robot that explores areas that are difficult for humans to reach. The robot periodically sends the distance it has traveled as input t your program. When the robot reaches its destination, it sends 0. Your task is to write code that reads the values sent by the robot and calculates their total. Assume that an int variable named totalDistance has already been declared and initialized. Write a do-while loop that performs the following steps: Reads an integer as input. This is the distance the robot has traveled. Adds the input to the totalDistance variable. The loop should repeat these steps until the input is 0. When the loop stops, your code should prin the message: Distance traveled:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
