In this problem a person is placed at the center of a 7 meter long bridge. Each step, the person moves 1 meter either forward or backward at random.
- Write a program that determines how many steps the person will walk before taking a step off the bridge. Have the program average 50 trials and report the average and greatest number of steps. Your C++ program should use top-down design and functions to solve the problem.
- Display the position of the person on the bridge at each stage of one bridge walk
Step 0: |---*---|
Step 1: |--*----|
Step 2: |-*-----|
Step 3: |--*----|
. . .
- Print a table of bridge length vs. average number of steps taken to get off.
Use 50 trials for each bridge length and try odd lengths from 5 to 21 meters long.
Length Average Number of Steps
What is the relationship between the length of the bridge and the average number of steps taken to get off?
Continue to: Unit 1