I've never been the best with math, and I've spent about half a day trying to come up with a solution to this, so any assistance is greatly appreciated.
Solve for $c$ and $a$. The value for $p$ is inputted by the end-user.
$$3c + 4a = p$$
Examples:
$$(168)(3) + (124)(4) = 1000$$ $$(152)(3) + (111)(4) = 900$$ $$(136)(3) + (98)(4) = 800$$
I need to find a solution to $a$ and $c$, where $3c$ is greater than or equal to $4a$. The products of $3c$ and $4a$ should be as close together as possible, assuming they are not equal.
I'm not sure what other information would be helpful here, but I'm happy to answer any questions you may have.
Thank you very much for your time!
p.s. Here is what I'm actually working on, in case you're curious: https://hastebin.com/voyuvobevu.gs
If you want $3c$ and $4a$ about the same, start with $c=\frac p6$ and $a=\frac p8$. If $p$ is a multiple of $24$ you are done. Otherwise, round them up to the next whole number and see how much you are over. Call it $k$. If you add $k$ to $c$ and subtract $k$ from $a$ you will get a total that equals $p$. Finally if the difference between $3c$ and $4a$ exceeds $24$, subtract $4$ from $c$ and add $3$ to $a$ and you will be closer.
As an example, let $p=67$. Our first division and roundup results in $c=12, a=9, 3c+4a=72$, an excess of $5$. Adding $5$ to $c$ and subtracting $5$ from $a$ gives us $3\cdot 17+4\cdot 4=67$, but that has $3c=51,4a=16$. As $51-16=35 \ge 24$ we can use $c=17-4=13, a=4+3=7$, giving $3\cdot 13+4\cdot 7=67, 3c=39,4a=28$