you should talk through in plain language what you are trying to do. It's always best to get your thoughts straight before coding. Are you computing how many years it would take to pay off a given debt? That would be when remaining debt is zero, not when the paid amount is more than zero. Think about how you'd solve the problem on paper first, then try to make a program to do it.
until and unless you decrement the variable "paid",
you will never get into that loop...
So that if "paid" is positive at first iteration then it goes into the loop...
then year is will increment... and "paid" is getting decremented... still
condition is true.... It should work like this....
mike sin wrote:Hmm, This is what I am basically trying to do
Debt - $1500
internet - 15%
payment - $100/mnth
end of year - (1500*0.15)+1500
payment at end of year = 100(12)
debt left(525) = end of year(1725) - payment at end of year(1200)
so it takes 1 year for all debt to pe paid.
If it took 1 year to pay all the debt, the debt left would be zero I would think. Even with no interest, 100 a month won't pay off a 1500 debt. I'm having trouble understanding where you come up with 1 year for debt to be paid off?
mike sin wrote:
Here's my try with do-while loop, year always returns 2 for some reason the loop only occurs once argh :/
I think your first problem is you mean while(debt>=0), since <0 would mean you have negative debt. Also, you aren't changing the amount of debt in your loop, so whatever debt you have going in is what will always be there.