Basic problems with writing functions. Program randomly skips to the end
<p>I'm very new to writing functions. This is my first attempt at using call by reference parameters specifically for a homework assignment. This program should calculate how long it takes to pay off a loan based on the users input of the amount they borrow, their monthly payment and the interest rate. The program should make sure the user doesnt input a payment number less than monthly interest amount and check for negative integers etc. </p>

<p>The area I commented out was my first go before i attempted to turn all of that into a function that uses call by reference parameters. At that point the program ran fine and i got output within a dollar of what I was looking for. After i rewrote the program like this and tried to make it a function, the program compiles but break to the bottom cout statements after asking for the interest rate. I assume my problem is somewhere within the interest1 function where i convert the percent to a decimal but i cant figure out why it would skip the rest of the functions afterwards. </p>

<p>Thanks for any advice you might have on this issue or anything else that looks wrong with the program itself.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
using namespace std;

double amount();
double interest1();
double pay(double amt, double interest);
void  payoff(double monthly, double Minpayment,double borrow,double interest, double&amp;   
totalinterest,int&amp; month);


int main()
{
 double monthly,month,totalinterest;

 cout &lt;&lt; fixed;
 cout &lt;&lt;showpoint;
 cout &lt;&lt;setprecision(2);

double borrow=amount();
double interest=interest1();
double Minpayment=pay(borrow, interest);
void payoff(double monthly,double Minpayment,double borrow,double interest,double&amp;       
totalinterest,int&amp; month);

/*
//   cout &lt;&lt; "What is the monthly payment amount? \n";
//   cin &gt;&gt; monthly;
//      if(monthly&lt;Minpayment)
//       {
//          cout &lt;&lt; "You must make payments of at least: " &lt;&lt; Minpayment++ &lt;&lt; endl;
//          cout &lt;&lt; "Because your monthly payment is " &lt;&lt; Minpayment &lt;&lt; endl;
//          cout &lt;&lt; "Dont get overwhelmed with debt!!!!!! \n";
//        }
//      else
//
//      {
//         int month = 1;
//         double totalinterest=0;
//         do
//          {
//            double Minpayment=pay(borrow, interest);
//            borrow=(borrow+Minpayment)-monthly;
//            totalinterest=totalinterest+Minpayment;
//            month++;
//          }while(borrow&gt;monthly);
*/  
         cout &lt;&lt; "Your debt will be paid off in " &lt;&lt; month &lt;&lt; " months \n";
         cout &lt;&lt;" with a final payment of " &lt;&lt; borrow &lt;&lt; endl;

         cout &lt;&lt; "You paid " &lt;&lt; totalinterest &lt;&lt; " in interest. \n";

return 0;
}

double amount()
{
double borrow,amt;
        do
        {
                cout &lt;&lt; "How much money do you want to borrow? \n";
                cin &gt;&gt; amt;

        if(amt&lt;1)
        cout &lt;&lt; "You must enter a positive number!";

        }while(amt&lt;1);
borrow = amt;
return  borrow;
}


double interest1()
{
double rate;
  do
  {
    cout &lt;&lt; "What is the annual interest rate expressed as a percent? \n";
    cin &gt;&gt; rate;
              if(rate&lt;1)
             cout &lt;&lt; "You must enter a positive number!";

  }while(rate&lt;1);

double interest = (rate/12)*.01;
return  interest;
}   

double pay(double borrow,double interest)

{

double Minpayment=borrow*interest;
return  Minpayment;  
}


void payoff(double monthly,double Minpayment,double borrow,double interest, double&amp; 
totalinterest,int&amp; month)
{
    cout &lt;&lt; "What is the monthly payment amount? \n";
    cin &gt;&gt; monthly;
      if(monthly&lt;Minpayment)
        {
          cout &lt;&lt; "You must make payments of at least: " &lt;&lt; Minpayment++ &lt;&lt; endl;
          cout &lt;&lt; "Because your monthly payment is " &lt;&lt; Minpayment &lt;&lt; endl;
          cout &lt;&lt; "Dont get overwhelmed with debt!!!!!! \n";
        }
      else
      {
        int month = 1;
         do
          {
            double Minpayment=pay(borrow, interest);
            borrow=(borrow+Minpayment)-monthly;
            double totalinterest=totalinterest+Minpayment;
            month++;

          }while(borrow&gt;monthly);
       } 
 }
</code></pre>
