Need help on this program logic
Hello,
I am really looking for help on this program as I felt its tough program... Please help me out on this program as I am very new and this is first time I am taking Java course...
Many Thanks,
Maria
Here is the program question...
A student decided to celebrate thanksgiving break early by getting a bit smashed... Here home is at corner 0 on the main street, and the jail is at corner 10 on main street. The student starts at corner 5 and wanders one corner to the left or to the right with probability of 0.5 for each. She repeats the process until arriving safetly at home or landing in jail. That is at each corner, the drunk student has a 50-50 probability of staggering left or right, to the next high numbered or next low numbered corner.
Write a method named dunkwalk() using a while or a do while loop that simulates student walk. The program should print whether she arrives at home or jail and have it return how many steps it took.
Program output will look like in action with N equal to '5'
Here we go again........time for a walk!
Took 37 steps and
Landed at HOME
Here we go again.........time for a walk!
Took 19 steps , and
Landed at JAIL
Here we go again.........time for a walk!
Took 13 steps, and
Landed in JAIL
Here we go again........ time for a walk!
Took 25 steps and
Landed in JAIL
Here we go again.......time for a walk!
Took 15 steps and
Landed at HOME
Average # of steps equals 25.4
Re: Need help on this program logic
Have you tried anything yourself yet?
kind regards,
Jos