Question
In Java Please. The small words say: The bean machine, also known as a quincunx or the Galton box, is a device for statistics experiments
In Java Please.
The small words say:
"The bean machine, also known as a quincunx or the Galton box, is a device for statistics experiments named after English scientist Sir Francis Galton. It consists of an upright board with evenly spaced nails or pegs in a triangular form as shown above.
Balls are dropped from the opening of the board Every time a ball hits a nail, it has a 50% chance of falling to the left or to the right. The piles of balls are accumulated in the slots at the bottom of the board.
Write a program that simulates the bean machine. The program should prompt the user to enter the number of the balls and the number of the slots in the machine. Simulate the falling of each ball by printing its path. For example the path for the ball in Figure (b) is LLRRLLR and the path for the ball in Figure (c) is RLRRLRR. Display the final buildup of the balls in the slots."
Program 7.2 Requirements (10 pts) (b) (c) The bean machine, also known as a quincunx or the Galton box, is a device for statistics experiments named after English scientist Sir Francis Galton. It consists of an upright board with evenly spaced nails or pegs in a triangular form as shown above. Balls are dropped from the opening of the board Every time a ball hits a nail, it has a 50% chance of falling to the left or to the right. The piles of balls are accumulated in the slots at the bottom of the board. Write a program that simulates the bean machine. The program should prompt the user to enter the number of the balls and the number of the slots in the machine. Simulate the falling of each ball by printing its path. For example the path for the ball in Figure (b) is LLRRLLR and the path for the ball in Figure (C) is RLRRLRR. Display the final buildup of the balls in the slots. Sample Run (user-entered data in red) Enter the number of balls to drop: 5 Enter the number of slots in the bean machine: 8 LRLRLRR RRLLLRR LLRLLRR IRRLLLLL LRLRRLR Slot 0:0 Slot 1:0 Slot 2:1 Slot 3:1 Slot 4:3 Slot 5:0 Slot 6:0 Slot 7:0 Hint: Create an array named slots. Each element in slots stores the number of balls in a slot. Each ball falls into a slot via a path. The number of Rin a path is the position of the slot where the ball falls. For example, for the path LRLRLRR, the ball falls into slots[4], and for the path RRLLLLL, the ball falls into slots[2]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