Results 1 to 2 of 2
Thread: Need help on this program logic
- 11-12-2011, 09:09 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 4
- Rep Power
- 0
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
- 11-12-2011, 09:14 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,589
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
need help in merging GUI and logic main program
By lavender88 in forum NetBeansReplies: 2Last Post: 04-02-2011, 01:28 PM -
Need help on logic
By nn12 in forum New To JavaReplies: 6Last Post: 03-10-2011, 11:06 AM -
need a logic for this
By rajivjoshi in forum New To JavaReplies: 4Last Post: 06-12-2010, 02:18 PM -
Separating program logic and GUI
By loopingman in forum AWT / SwingReplies: 0Last Post: 12-08-2008, 02:46 PM -
Cant get the logic right
By jermaindefoe in forum New To JavaReplies: 4Last Post: 03-11-2008, 12:22 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks