Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Requirements for your program: 1. Output the correct answer. 2. The running time must be less than 10 seconds (as shown in the Netbeans output
Requirements for your program:
1. Output the correct answer.
2. The running time must be less than 10 seconds (as shown in the Netbeans output window).
3. Demonstrate Object-Oriented program design.
4. Follow Java naming convention and programming style.
5 . Any other classes should be private static classes inside the main class.
Sky performs a random walk from his home. He makes a random decision to go either up, down, left or right in each step. If he is more than 4 blocks away from his home, he will need to take transport back home; otherwise, he walks home. The question is: What is the longest random walk he can take so there is more than a 50% chance he can go home on a walk? Note that the length of the random walk is the total number of steps of the path, and the distance from home is x+y. Write a Monte Carlo simulation program to find the answer to the above question. If your program runs correctly, it should output the following answer, in which the estimated percentage may vary but is close to 51%. The last value, no. of iterations, is a simulation parameter you need to estimate by yourself and display in the output. The value indicates the number of iterations used to estimate the walk-home-chance for a random walk of a particular length. Output - JLab (run) x run: The tongest random walk =22 The chance of watking home =51.03 w No. of iterations used in the simulation = ? BUILD SUCCESSFUL (total time: 1 second)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started