# Homework help

Show 80 post(s) from this thread on one page
Page 2 of 2 First 12
• 03-24-2012
whiteflags
Quote:

Originally Posted by arsenalftw067
the program now shows how many times I rolled each number but no th

It doesn't show what now?
• 03-24-2012
arsenalftw067
Not the percentage of each rolled number
• 03-24-2012
whiteflags
I see. You use expressions like this:

(num3/times_rolled)*100

The major issue is that since both times_rolled and num3 (but numN in general applies to this) are integers, integer division takes place. If you want an answer other than zero, you need to cast one of the dividing terms to say, float, to yield percentages.
• 03-24-2012
arsenalftw067
So I would have to have the num1 num2 etc all in floats?
• 03-25-2012
Elysia
No, it means you should do
(static_cast<float>(num3)/times_rolled)*100
Now num3 will be converted into a float in this calculation which means you will do a floating point division which will keep the decimals.
Show 80 post(s) from this thread on one page
Page 2 of 2 First 12