To walk, the robot must receive input in meters, how long it has to walk. The robot will compute the distance it has moved every 1 meter. The process of checking the distance will be repeated every 1 meter until it finishes the movement.

My Pseudo code Design:

start
num walkingDistance
num distanceMoved = 0

Display "Enter the distance (in meter) : "
Get walkingDistance

for (count = 1 to walkingDistance)
 distanceMoved = distanceMoved + 1
endfor
end

Is there any problems on my design? Any help is much appreciated.

Read the attached

Your logic should answer the kid's annoying questions on long trips:

"Are we there yet?"

while(1) {
  if distance == goal) {
    stopWalking();
    printf("Goal reached\n");
    break;
  }else {
    takeAstep();
    //assumes each step is 1 meter
    printf("I have %d more meters to cover\n", --distance);
  }
}

In humans, walking is a forward lean accompanied by taking steps. Same thing with robots, except they don't do well with the energy saving forward lean aspect of it. It still saves energy, but if you don't limit it, they'll fall over. They have no sense of balance, as we do, unless you build it into them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.