View Single Post
Old 05-26-2010, 09:43 PM   #4
sureLoss
Some kinda newsbreaker!
 
sureLoss's Avatar
 
Join Date: May 2004
Location: Learning Phaneufs skating style
Exp:
Default

Its an issue of integer division.

when you divide an integer by an integer it will return an integer. For example 25/100 will return 0 but 25/100.0 will return 0.25 in most programming languages.

You need to cast the divisor to a float.

Console.WriteLine("Number of Heads: {0} ({1}%).", heads, (heads / (double) numOfTosses) * 100.0);

edit this will work also:
{(heads * 100.0) / numOfTosses},

Last edited by sureLoss; 05-26-2010 at 09:57 PM.
sureLoss is offline   Reply With Quote
The Following User Says Thank You to sureLoss For This Useful Post: