Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Class a challenge let’s suppose you need to design the algorithm that will allow

ID: 671362 • Letter: C

Question

Class a challenge let’s suppose you need to design the algorithm that will allow a robot to move from one chair to another placed directly in front of it. The distance between the two chairs is not fixed and can change each time the algorithm must be used.

The instructions that can be used to direct the robot are:

1) stand up

2) take a step

3) turn around

4) sit down.

The robot can also answer a single question, "Am I touching something?"

Write a short pseudocode algorithm that will instruct the robot to move from one chair to the other.

Explanation / Answer

task main()
{
while ( touch sensor is not pressed )
{
Robot stand up and take a step

if (sonar detects object < 20 cm away)
{
Robot stops
Robot turns right
}
}
}