I need help writing this program (short)

closed account (92w05Di1)
I'm new to programming, i'm getting the hang of it, but my teacher gives a lot of confusing math problems.
I just can't figure out how to do this for the life of me.

Question:
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)



Help is greatly appreciated.
solve for x: a*x+b*(s-x) = 100*R
closed account (92w05Di1)

This is what I have so far, but I get this error with it:
error C2106: '=' : left operand must be l-value
----------------------------




#include <iostream>
using namespace std;

int main()
{
int s;
cout << "Enter Royalty:" << endl;
cin >> s;
cout << "Enter % Interest A:" << endl;
int a;
cin >> a;
int b;
cout << "Enter % Interest B:" << endl;
cin >> b;
int r;
cout << "Enter $:" << endl;
cin >> r;
int x;
100*r=a*x+b*(s-x);
cout << x << endl;
system("pause");
return 0;
}
double S,a,b,R,result;
cin >>S >>a>>b>>R;
result = (100*R - b*S) / (a -b);
closed account (92w05Di1)
thanks
Topic archived. No new replies allowed.