> I need help with 2 programming 2 different math problems.?

I need help with 2 programming 2 different math problems.?

Posted at: 2014-12-05 
Let x = the percentage (e.g. weight) in decimal form of the amount of the total $ invested at a%, then (1 - x) is the weight of the total invested at b%. Use decimal forms of the interest rates.

1) $R / $S = total return in decimal form, let's call this TR

2) [x(a)] + (1 - x)(b) = TR, and reduce...

xa + b - xb = TR

xa - xb = TR - b

it's a little easier to show you the rest with an example...

example: $1000 total, interest earned is $32, a = 0.02, b = 0.05

32 / 1000 = 0.032 TR

x(0.02) + (1 - x)(0.05) = 0.032

0.02x + 0.05 - 0.05x = 0.032

-0.03x = -0.018

x = -0.018 / -0.03

x = 0.60, or 60% of the total $ was invested at 2%, thus (1 - x) = 0.40, or 40% was invested at 5%

x($1000) = 0.60 * 1,000 = $600 and

(1 - x)($1,000) = 0.40 * 1,000 = $400

check math:

$600 * 0.02 = $12

$400 * 0.05 = $20

total interest: $32

2) equally weighted: 1/3 = 0.3333, again, using decimal forms of rates, here "x" equals total $

0.3333x(a1%) + 0.3333x(a2%) + 0.3333x(a3%) = $S

The first one:

A guy received $ S as royalty for his book. he invested part of it in bonds paying a % interest annually. The rest he invested in a life insurance policy paying b % interest annually. If the total interest from the investments after 1 year is $R, how much did he invest in bonds? (Enter S, a, b and R, calculate investments and output result)

2. When equal amounts are invested in each of three accounts paying a1% a2% and a3% interest, one year's combined interest income is $S. How much is invested in each account?(Input a1, a2, a3and S. Calculate and output result)