Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

3. Comment on how diversity and equality should be managed.

Answered: 1 week ago

Question

describe the legislation that addresses workplace equality

Answered: 1 week ago