I have a variable called $poits
which has numerical values, of that variable I need to show its values in percentage between the 1
to 100%
, which the condition to reach 100%
that variable must have a value of 1000
(thousand) points, to reach the 100%
.
From that same variable I need another option to be able to pass to dollars, the condition is that if that variable has the value of 1000
(thousand), it prints a profit of $5.00
dollars, but if it has another value that shows how much it is generating, say yes It only has a value of 30
, this shows in dollars the percentage I imagine to say $0.00012
for $5.00
.
My idea is to show a graph with the percentages, and at the same time show you your earnings according to the graph.
Try processing your values by simple rule of three and save your calculations in an associative array:
here the demo
Could be like this:
Sample: See Sample
That code if the user obtains more than a thousand points, calculates his profit exponentially, it is simple but I think it is what you need to guide you.
As I understand it, what you need is something like deferring how much the person should earn for each point obtained, having as a limit
100
points and5,00
dollars, then it should go as follows:I hope it helps you a lot bro and mark it XD... ReNiceCode...
Values
To calculate the percentage
To calculate how much it is in dollars, just multiply how much is the maximum "5" with its percentage based on 1, that is: 5 x 0.18 = 0.9 dollars