0

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.

  • 2
    I would do it like this: $4+2+5=11$ and budget Food importance would be $\frac{4}{11} 1000$ and the budget of housing importance would be $\frac{2}{11} 1000$ and budget comfort would be $\frac{5}{11}1000$ – Sina Babaei Zadeh Mar 04 '20 at 19:48
  • 1
    While the ratio method in @SinaBabaeiZadeh's comment is mathematically natural, I would caution you against doing this in your program. There's no reason to think that people's preferences on 1–5 scales should be proportional to the amount of money they spend on things. (Maybe I rate housing as 1 and food as 5, but am I really going to spend five times as much money on food as I do on housing?) It's so likely to provide harmful answers to users. This is a huge pitfall with math: just because we can get math to give us an answer doesn't mean that it's a reasonable answer. – Greg Martin Mar 04 '20 at 19:53
  • @GregMartin you are absolutely right. I made a lot of assumptions that may work in theory that may fail in real life. So OP please provide some more details/ take into account the real life applications. – Sina Babaei Zadeh Mar 04 '20 at 20:13
  • I suppose the solution to this is increment housing by 2 automatically(in addition to what the user enters from 1 - 5). Thank you for the help! – ckaepie Mar 04 '20 at 20:56
  • @ckaepie No, that is just as arbitrary and unlikely to be useful. One would literally need to gather some statistics on how much these categories actually cost in real life, and correlate them with the importance-preferences of the spenders. Please, please do not just invent a formula. – Greg Martin Mar 04 '20 at 21:21
  • Sorry I should have said it earlier this is just a practice program so no one will actually be using it! Thanks for the heads up if later I were to ever make a legit program like this I would have to do research first. – ckaepie Mar 04 '20 at 22:24

1 Answers1

0

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}.$$

Bernard
  • 175,478