# C ++ composite interest function

Ok, after working on this for an embarrassing number of hours, I think I came up with something less cringe-worthy to ya'll "real" programmers.
Allow me to submit my humble and probably awful code.
It totally works, but now my issue is that I'm trying to make it go back to an initial question if the response is a negative number. I got it to say, "Hey! Don't put in a negative number!", but then it goes to the next prompt. Here's my current output for a negative input:

** Welcome to the Consumer Loan Calculator ** How much would you like to borrow? \$-100 Please enter a positive loan amount. What is your annual percentage rate? %

...And for a positive input:

** Welcome to the Consumer Loan Calculator ** How much would you like to borrow? \$100 How much would you like to borrow? \$100 How much would you like to borrow? \$

I want it to go back to "How much would you like to borrow?" if the user input is negative and only go to the next question if the input is positive. What am I doing wrong now?

``````#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
using namespace std;

void get_input (double &principal, double &APR, double mon_pay);

int main()
{
double loan; // principal
double APR; // APR
double mon_pay; //monthly payment

cout << "** Welcome to the Consumer Loan Calculator **"<<endl;
do {
cout << "How much would you like to borrow? \$";
cin >>loan;
if (loan < 0)
cout <<"Please enter a positive loan amount.";
}
while (loan > 0);
cout << "What is your annual percentage rate? %";
cin >>APR;
cout << "What is your monthly payment? \$";
cin >> mon_pay;

APR = APR/100;
get_input (loan, APR, mon_pay);

}

void get_input (double &principal, double &APR, double mon_pay)
{
double total, add=0; // Total payment
int tpay=1; //Total months of payment

while (principal > 0)
{
tpay++;
}

total = mon_pay + principal;
cout << "Your debt will be paid off after "<< tpay << " months, with a final payment of just \$" <<setprecision(3)<<total<<endl;
cout <<"Don't get overwhelmed with debt!"<<std::endl;

}
```
```

this line is definately wrong:

``````while (int tp=1, double p <= double m, double sub--m)
```
```