help me please!!!!! :(

Hi everyone, i've been trying to get this program to work for about 15 hours now and I dont understand why it won't work. I have tried trouble shooting and debugging myself but i'm failing to understand exactly what's wrong with my program. I'm trying to get the moneyowed to subtract 10000-principle. Principle is 3000-interest which means it SHOULD be subtracting 225, 226.69, etc etc after 2 months. instead it is giving me this error. I'm not asking for you to do this for me but just to point me in the right direction :( Thank you for your time in advance!

I have been loaned $10,000.00 for my vehicle.
Month Money Owed
-----------------------
2 9775
3 9773.32
4 9771.64
5 9769.96
6 9768.28
7 9766.6
8 9764.92
9 9763.24
10 9761.56
11 9759.88
12 9758.2
13 9756.52
14 9754.84
15 9753.16
16 9751.48
17 9749.8
18 9748.12
19 9746.44
20 9744.76
21 9743.08
22 9741.4
23 9739.72
24 9738.04
25 9736.36
26 9734.68
27 9733
28 9731.32
29 9729.64
30 9727.96
31 9726.28
32 9724.6
33 9722.92
34 9721.24
35 9719.56
36 9717.88
37 9716.2
38 9714.52
39 9712.84
40 9711.16
41 9709.48
42 9707.8
43 9706.12
44 9704.44
45 9702.76
46 9701.08


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;
int main()

{
 
float interest, principle, moneyowed, num, x;
        //these four lines are for the first month
        cout <<"I have been loaned $10,000.00 for my vehicle." << endl;
        cout <<"Month \t Money Owed" << endl;
        cout <<"-----------------------"<<endl;
        num=1;
        while (num<46)
        {
                x+=(1.69-.01);
                interest=(76.68-x);
                principle=(300-interest);
                moneyowed=(10000-principle);
                num++;
                cout << num << "\t" << moneyowed << endl;

        }
        return 0;
}
You could start by playing around with your equations. I just finished a project like this. If you can find out the actual interest rate
(ex. 5.25%) then you could just multiply that by your moneyowed to find interest and use that to find principle and so on. If you play around a little more with different equations then you will be able to better see what your program is actually doing.
Look at your calculation of moneyowed.

Iteration X Interest Principle MoneyOwed
1 1.68 75.00 225.00 9775.00
2 3.36 73.32 226.68 9773.32 (We are subtracting principle from 10,000 not money owed)

How about setting moneyowed to equal 10,000 and replacing the 10,000 in your code with the variable moneyowed so it is updated with each iteration?
ddwinters45,

are you suggesting i change in my loop moneyowed=10000; and then moneyowed=moneyowed-principle;? im a little confused :( or are you saying to place moneyowed=10000; outside of the loop and then place moneyowed=moneyowed-principle inside
of the loop? again thank
you so much for your help!
Set moneyowed = 10,000 outside of the loop and then in the loop place moneyowed = moneyowed - principle. This should give you the results you are looking for. Does it make sense why you would do this instead of what you are doing?
i thought about doing that but in my
mind if 10000 is outside of the loop and then its moneyowed=moneyowed-principle wouldnt it just do 10000 = 10000 - 9775
after the first month? that didnt make sense to me :( im an idiot.
No, it is a common misconception. The current value doesn't play a role on the left side of an equation (except in situations like where you used += in which case it does). Really what moneyowed = moneyowed - principle is doing is saying take the current value of money owed, subtract the principle from it, and then store it into moneyowed. You could accomplish the same thing by saying moneyowed -= principle if that makes more sense to you.

If you were to use == then this would compare the two values, and yes it would return false because the two are obviously not equal (unless principle equaled 0 at some point).
Last edited on
thank you so much for all of your help!!!
No problem.
Topic archived. No new replies allowed.