EDIT: I've got it, thanks for all the help everyone! + Cleaned up post a little bit.
Also, this article was very helpful: http://www.codinghorror.com/blog/archives/001204.html?r=1183
Hi all,
I've been asked (as part of homework) to design a Java program that does the following:
Basically there are 3 cards:
- Black coloured on both sides
- Red coloured on both sides
- Black on one side, red on the other side
Now if I take a card randomly and place it on the table. The side facing up is black. What is the probability that the other side is also black?
Implement a program using Java and try to discover the probability, the program should simulate the card trick a large number of times and should output the probability that the other side of the card is black (it does this by counting how many times the other side also black).
However I've been told that my code is wrong (algorithm wise)... apparently the answer should not be 0.50. Have I made a mistake in trying to understand the algorithm?
Can anyone point me in the right direction please? (I'm not asking you to provide me with a fully working implementation, just on how the algorithm should work).