Simple C++ Bean machine program @KTSI

This is a simple Bean machine program done in C++ for KTSI.

This is how it works, you drop 100 balls and they fall in 6 different boxes.

Bean MachineAnd this is how the C++ output should look like:

Bean Machine outputAnd here is how its done:

#include 
#include 
#include 

using namespace std;

int main (int argc, char * const argv[]) {
	
	
	// initial
	int ballCount = 100;
	int box[6] = { 0, 0, 0, 0, 0 };
	string line = " +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-->";
	string numbers = " 0     5     10     15     20     25     30     35     40     45     50";
	int leftorright = 0;

	// Need for Random Numbers
	srand ( time(NULL) );
	
	// Rund ballCount (100) zahl = rand() % 2;
	for (int i=0; i

I also did this program in Powershell

One response

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.