int percent = (score/numberOfQuestions)*100;
progressText.setText(score+\"/\"+numberOfQuestions+\" \"+percent+\"%\");
returns 0% no matter what I
You're using an int
(integer) to store that percentage. Try using float
or double
instead making score and number of questions float
or double
too (Thanks for teh comments, I totally skipped this...). If you have issues showing the value, I suggest you use DecimalFormat to format it.
Rather than using pure int
math to calculate and store the percentage, I suggest this other alternatives if you want to have decimals in your result.