Stumped! PLINKO!

closed account (16MjE3v7)
Upon encountering a peg, a chip has a 50/50 chance of going left or right. During simulation, I need to report the location of the chip as it falls so like for the left path it would be: [3.0 3.5 3.0 2.5 3.0 2.5 2.0 2.5 3.0 3.5 4.0 3.5 4.0]

Point is that I have been messing around with loops and rand. I just can't get it to work. I have the rest of the program going flawlessly. Anyone have a model that would solve this problem?

HERE IS THE IMAGE BELOW
[IMG]
http://i171.photobucket.com/albums/u319/anchorblue804/plinko_zps0c718e27.png
[/IMG]
great and nice sharing, appreciated
closed account (16MjE3v7)
ha what
@anchorblue804

Can we see the code? It seems to me, it would be easier to figure out a way, if we knew what we had to work with.
closed account (16MjE3v7)
Here is what I have so far...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>

using namespace std; 

int main()
{
int choice;
int selection;
double user_winnings;

bool gameOn = true;
while (gameOn != false){
cout << "***PLINKO MENU***\n";
cout << " 1 - Drop one chip into one slot.\n";
cout << " 2 - Drop multiple chips into one slot.\n";
cout << " 3 - Exit.\n";
cout << " Enter your choice and press enter: ";

cin >> choice;

switch (choice)
{
case 1:
	bool tf = true; //flag, whether the first or second condition's happened
	cout << "\n Which Slot would you like to Drop a chip in(Please enter a slot #0-8)?"<<"\n";
cin >> selection;
if((selection < 0) || (selection > 8))
{
	break;
}
else; 
//simulation description
	cout<<"You've won $" << "money" << "!" << endl;
break;

break;

case 2:
cout << "\n Which Slots would you like to Drop a chip in(Please enter a slot #1-9)?"<<"\n";
// rest of code here
break;

case 3:
cout << "End of Program.\n";
gameOn = false;
break;

default:

cout << "Not a Valid Choice. \n";
cout << "Choose again.\n";
cin >> choice;
break;
}

}
return 0;
}
@anchorblue804

Sorry, but that does not look like a program that would be working flawlessly. I see no rands, loops, or program even. Looks to me like your hoping someone will do it for you. Maybe someone will. Good luck..
You shouldnt get people to do your homework for you. Atleast code it and if you have problems ask for someone, yanno?
http://students.cs.byu.edu/~cs142headta/homework/labs.php?lab=4
Topic archived. No new replies allowed.