problem with calculations
in
Programming Questions
•
11 months ago
Hey guys
I want to have a variable where i can put in a percentage of the calculation. so i can adjust it by changing the variable.
only the calculations that processing does are not correct. its probably the way i typed it but i cant figure it out.
here is my code:
- int a = 2;
- int b = 2;
- int percentage = 75;
- float total = a * b/ 100 * percentage;
- println(total);
the solution has to be 3. but it returns 0. i cant use it in my program like this because its inaccurate.
maybe you guys know how I have to type it that it works.
Thanks in advance
1