return 0;
}
// sorry about the format. I don't know how to do it the other way.
// The problem with my code is tp(total percentage) and it won't calculate the math correctly.
In math you can give an equation before you provide values, but the equation cannot be used until you have values. For example, I can say:
y = mx + b
then say:
m = 1/2, b = -2, x = 2
At that point, you can go back and plug in the values to get y = -1.
The computer never goes back. You have to tell it what to do, and when. Which means that you have to get m, b, and x before you can tell it what to do to get y.
int counter = 1;
int wrong = 1;
int correct = size - wrong;
float tp = correct / size;
The last statement will do integer division of correct/size to generate an integer result. The integer is then converted to float and stored. You want the conversion to happen earlier than that. So try:
float tp = (float)correct / size;
This will convert "correct" to a float. That sets up a sort of chain reaction: to do the division, the compiler converts "size" to a float also, does division and then assigns the result to tp.
The second problem is more serious. When you say "tp = (float)correct / size;" it simply computes the value of correct/size and assigns it to the variable tp. If "correct" or "size" change later on, it does NOT update tp automatically. So you have to set tp later on in the code.