Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use java i want to understand the logic of this java program . Sky performs a random walk from his home. He makes a random

use java

i want to understand the logic of this java program .

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

List the benefits of strategic planning.

Answered: 1 week ago