1. ## endless looping problem

Hi I'm sorry if this seem quite lame because for me it is as well
I'm currently writing a program using Microsoft Visual 6 C++
my program is as such
Code:
```//This program is used to loop a number untill the value is found.

#include <iostream>
#include <iomanip>
using namespace std;

void main()
{
float value;
value = 1000;

int number;
number = 0;

float interest;
cout.setf(ios::fixed);
cout.precision(2);

float totalInterest;
totalInterest = 0;

float amount;
amount = 50;

while (value > 0)
{
interest = value *  0.15;
amount -= interest;
value -= amount;
totalInterest = totalInterest + interest;
number++;

cout<<"The amount of times this process is repeated is "<<number<<endl;
cout<<"The total amount of the interest is "<<totalInterest<<endl;
cout<<"The amount left is "<<value<<endl;
}
}```
this program of mine will loop endlessly if the value is 1000, but if the value is 100 it will provide me with the proper answer please help me out.

2. Code:
```	while (1)
{
interest = value *  0.15;
amount -= interest;
value -= amount;
totalInterest = totalInterest + interest;
number++;

if (value == 100) {
break;
}
else {
cout<<"The amount of times this process is repeated is "<<number<<endl;
cout<<"The total amount of the interest is "<<totalInterest<<endl;
cout<<"The amount left is "<<value<<endl;
}
}```

3. So 15% of 1000 is 150, which means \$50 a go won't even pay off the interest on the loan, let alone pay down the debt. Perhaps you intend to compute the payment value in some way.

4. no, the way im trying this problem is like this to create a program which will calculate the amount of interest i need if i have different values (such as \$100 or \$1000 or even \$1 million) with in mind my own budget which is \$50.
the interest program im going through is in a month ill be paying the interest as well as the debt with the \$50. the interest is the debt's (value) 1.5% which = 0.15.

If there is any way in solving it please tell me.
And thanks very much to those that are willing to give me a hand.

5. after asking some of my colleagues, i found out that i needed to tell the program to read the value in 2 decimal places. So after doing some manual calculation i discovered that the looping process should not be more than 25-30 (and its possible for it to be less) so if thats the way please tell me how to do it.
ive tried the cout.precision but as i know that is only to display the value in the desired decimal places.

6. Originally Posted by SoulMagician
no, the way im trying this problem is like this to create a program which will calculate the amount of interest i need if i have different values (such as \$100 or \$1000 or even \$1 million) with in mind my own budget which is \$50.
the interest program im going through is in a month ill be paying the interest as well as the debt with the \$50. the interest is the debt's (value) 1.5% which = 0.15.

If there is any way in solving it please tell me.
And thanks very much to those that are willing to give me a hand.
1.5% is not 0.15. If you need to calculate the payment consisting of the interest owed plus 50 dollars then do so. (You'll be paying much more than \$50 a month, though.)

7. Originally Posted by tabstop
1.5% is not 0.15. If you need to calculate the payment consisting of the interest owed plus 50 dollars then do so. (You'll be paying much more than \$50 a month, though.)
hm im sorry, my mistake, after a some coffee and recalculation i discovered its actually 0.015. Which when multiplied to \$1000 becomes only \$15. Sorry for the confusion.

8. after changing the program a bit, i still couldn't solve it

heres the new program <Though it doesnt have much of a difference>

Code:
```//This program is used to find the amount of time needed to compleete the payment of value
//with the interest rate of 1.5% and where the user can only spare \$50 to pay off
//everything. Meaning out of the \$50, the user must pay the interest which is 1.5% of the debt
//and the leftover of the \$50 is used to pay off the debt.
#include <iostream>
#include <iomanip>
using namespace std;

void main()
{
float value;
value = 1000;

int number;
number = 0;

float interest;

float totalInterest;
totalInterest = 0;

float amount;
amount = 50;

while (value > 0)
{
interest = value *  0.015;
amount -= interest;
value -= amount;
totalInterest = totalInterest + interest;
number++;

if (value == 100)
{
break;
}
else
{

cout<<"The amount of times this process is repeated is "<<number<<endl;
cout<<"The total amount of the interest is "<<totalInterest<<endl;
cout<<"The amount left is "<<value<<endl;
}
}
}```

9. You need to reset amount to \$50 every time.

10. You need to reset the amount to \$50 every time
sorry for the late reply, i was a bit busy with many stuffs this past few days. Anyways im sorry to say i don't exactly understand what do you mean tabstop

11. thanks tabstop i finally understood
THANK YOU VERY MUCH *bows*