Question: Write a program that simulates the Bean machine (Wikipedia). (Java) Balls are dropped from the top opening of the board. Every time a ball hits
Write a program that simulates the Bean machine (Wikipedia). (Java)
Balls are dropped from the top opening of the board. Every time a ball hits a pin it has 50% chances of going left or right. Finally, all balls are accumulated in the slots the bottom of the box.
The program should ask the user to specify the number of balls and the number of slots. It should display the all paths taken by the balls as sequences of L and R depending on where that ball went. Finally, it should show the final disposition of the balls as a horizontal histogram (see Figure for an example of horizontal histogram)
Example:
Number of balls to drop
> 5
Number of slots:
>8
Paths:
LRLRLRR
RRLLLRR
LLRLLRR
RRLLLLL
LRLRRLR
Disposition:
o
o
ooo
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
