# Algorithm not working?

Ashley Kin

Ranch Hand

Posts: 36

Bob Bilfred

Greenhorn

Posts: 7

posted 4 years ago

- 1

There isn't really a problem with the code since it does what was typed. Since both "wins" and "numberOfGames" are integers, when you divide them, you also get an integer. This calculation will also result in a decimal number, not an integer. Therefore, dividing two integers, say 6 and 10, will not be 0.60, it will be 0 since integers remove the numbers after the decimal point. Therefore, we need to cast "wins/numberOfGames" to a double. In order to do this, write the following instead...

Campbell Ritchie

Sheriff

Posts: 48652

56