Join 136,172 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,928 people online right now. Registration is fast and FREE... Join Now!
Well your first problem is that you define a variable called "begBalance" but then you attempt to immediately use it in the statement
CODE
monInt = begBalance * (0.10/12);
Remember, if you are going to use it in a calculation you must first set it to a value. Until you do that, it is sitting there as NULL. So when you define begBalance, try setting it to a beginning value BEFORE you use it in the multiplication.
It may start at 7999 because you subtract one using the line...
CODE
totalPrin = begBalance--;
With such a line you are assigning the value begBalance to totalPrin, but then you are decrementing it. So its value will be 7999 from that statement on.
Now I don't know what you have taken out or put in, but these two situations are probably what are causing your errors.
Well I'm very new to the forums, so I'm not sure how much of the solution I can post up. What it looks like to me is you have this class defined, and then never use it in main. There's really no reason to declare all these variables:
When you have them all hanging out in your Balance class. What you really want to do is construct a Balance object in main. Then all of your variables you are modifying and printing are contained in this object.
Also, it looks like you gave up on defining your constructors halfway through. If you initialize all your member variables in your constructor, you don't have to touch them untill you want to use them. Then, you could just do something like this:
while(balance > 0) { begBalance = balance; monInt = begBalance * (0.10/12); prin = paid - monInt; // you rewrite this later, so don't do it // balance = begBalance - prin; // this says, um, make cumInt = monInt and then add 1 to monInt // cumInt = monInt++; cumInt += monInt;
// not the best logic -- if(begBalance < 100) // this will always work if(begBalance < prin) { prin = begBalance; } balance = begBalance - prin;
Crap...I knew I forgot something...*hoping my instructor doesn't catch the comments* lol
But seriously, after a little tweaking, I finally got it. And Baav, I thought for a minute why wouldn't my if statement not work all time. I get it now..