Question: IN JAVA PLEASE Write a int method named randomWalk(int x) that performs a random one-dimensional walk, reporting each position reached and the maximum position reached

IN JAVA PLEASE
Write a int method named randomWalk(int x) that performs a random one-dimensional walk, reporting each position reached and the maximum position reached during the walk. To do a "random walk", you begin at position 0. Then, on each step, you should either increase or decrease the position by 1 (with equal probability). The walk stops when x or -x is reached. It should then print out the steps and return the number of steps that it took. Once your method works, make a main that calls your function for x = 30. Sample Output The output should look like this for random Walk(10): position = 0 position = 1 position = 0 position = -1 position = -2 position = -1 position = -2 position = - 3 position = -4 position = -5 position -4 position = -5 position = -6 position = -7 position = -8 position = -7 position = -8 position = -9 position = -10 Steps : 219
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
