but for some reason it always give 0% for the grade.
That is because in the following line all of your values are integer values.
Code:
percent = (correct/20) * 100;
So when you divide correct by 20 you get a number that is greater than zero but smaller than one. And using integer math this will evaluate to zero. And since zero times anything is zero you will always have a zero answer. To fix this problem insure that at least one variable is a floating point value. So for your calculation change it to:
Code:
percent = (correct / 20.0) * 100.0;
Also insure percent is a floating point type.
Jim