Hi, my algorithm (wins/numberOfGames)*100 is not working; it's printing out 0 every time, even though all four other variables are working fine.
Is my algorithm itself not correct?
I just assumed win% means the percentage of games won.
Thanks as always!
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...
Another way to do it is to move the 100 * to the beginning of the formula. () unnecessary, and can actually cause errors, so no (). Beware: you can get overflow problems with large numbers, and 100 * 999 / 1000 will come out as 99%, not 99.9%.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com