# solved

in C#
Hi all.

I'm new to C# and i'm trying to create a program that simulates Martingale's system of coin toss betting.

Problems i'm facing now:

1)Generating fair coin tosses with the Random function
2)Comparing the current toss with the previous tosses to invoke Methods

I've read through several beginners guides and know the basics, but I cant find anything specific to these problems highlighted above.

Any help would be greatly appreciated.

Thanks!

-solved-

• So the betting theory assumes a ficticious better with an infinite amount of money. It is based on the theory that the flip of a coin will always eventually even itself out. The betting method is to start with a bet - let's say 1 dollar - and then double it every time you lose. This way you eventually make back all of your money lost, plus profit.

Am I remembering that right?

Try this...

[code]
Random rnd = new Random();
double bet = 1.0;
double winnings = 0.0;

do
{
Console.WriteLine("Current Winnings: " + winnings);
Console.WriteLine("Betting " + bet + " on heads:");
Console.WriteLine("Press any key to proceed...");
var flip = rnd.Next(100);// 100 gives us a more even chance
if (flip >= 50)
{
Console.WriteLine("Winner!");
winnings += bet;
}
else
{
Console.WriteLine("Loser!");
winnings -= bet;
bet *= 2;
}
} while(true);

[/code]
><//~Psightoplasm`~