How to divide an amount to 3 ratios

30 Views Asked by At

I am making a budget calculator program. In it, the user will select the importance of food, housing, comfort from an IMPORTANCE scale of 1 - 5. After that they will provide a budget.I will divide the budget based on how important each thing is for them and display it to them.

I'm confused how the math behind this will work. So it the user has a budget of 1000, and then chooses Food Importance = 4, Housing Importance = 2, Comfort Importance = 5. How do I divide the 1000 so that it dives accordingly without going above or below 1000.

1

There are 1 best solutions below

0
On BEST ANSWER

It simply uses middle-school results on proportions:

Taking the numbers for importance from your example, and denoting $f, h$ and $c$ the parts of the budget for food, housing and comfort respectively, we require that $$\frac f4=\frac h2=\frac c5.$$ Now this common ratio is also the ratio of $$\frac{f+h+c}{4+2+5}=\frac{1000}{11},$$ taking into account that the total budget is equal to $1000$. Therefore $$f=\frac{4000}{11},\quad h=\frac{2000}{11},\quad c=\frac{5000}{11}.$$