The program should take the number of steps as an input


1. Suppose you are doing a random walk (see previous problem) on the blocks of a city street. At each "step" you choose to walk one block (at random) either forward, backward, left or right. In n steps, how far do you expect to be from your starting point? Write a program to help answer this question.

2. Write a graphical program to trace a random walk (see previous two problems) in two dimensions. In this simulation you should allow the step to be taken in any direction. You can generate a random direction as an angle off of the x axis.

1760_ba1a7c9a-d9d7-4984-b8c7-0ef7c8e6a765.png

The new x and y positions are then given by these formulas:
x = x + cos(angle)
y = y + sin(angle)

The program should take the number of steps as an input. Start your walker at the center of a 100x100 grid and draw a line that traces the walk as it progresses.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: The program should take the number of steps as an input
Reference No:- TGS01707768

Expected delivery within 24 Hours