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
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