TeemoBiceps TeemoBiceps - 8 months ago 39
Java Question

Get the percentage of a value between two values

I have a minimum value and a maximum value (The values can change).
I also have a value that is in between of these two values.

private int minValue = 201;
private int maxValue = 500;
private int currentValue = 482

Now I need to get the percentage of the currentValue between 0% and 100%.
Is this even possible?

Thank you for your help!


I think what you want to have is this calculation:

double percentage = (currentValue - minValue) / (maxValue - minValue);

Just like @kevin-esche wrote in the comments.