title: How could I properly set up this loan equation based on my code?
body: <p>The question wants me to create 2 scenarios </p>
  
  <ol>
  <li>The user accepts the dealer’s rebate offer and finances the car through his or her local credit union.</li>
  </ol>
  
  <p>and</p>
  
  <ol start="2">
  <li>The user declines the dealer’s rebate offer but accepts the dealer’s lower financing rate.</li>
  </ol>
  
  <p>It expects for me to use the periodic payment formula, which is: principal * rate / (1 – (rate + 1)-term) and use it to get either a monthly or annual payment.</p>
  
  <p>The problem that I am having with my code I believe has something to do with my equations I am using to get annual or monthly loan payments, it for sure is not giving me the correct answer to my inputs and I do not know why. </p>
  
  <p>I have tried changing the equations around several times and still no avail.</p>
  
  <pre><code>int main()
  
  
  // these are the variables I will be using in maths for this project
  double annualpayment; // what will be displayed once all is calculated annually 
  double monthlypayment; // what will be displayed once all is calculated monthly
  double prinicple; // amount borrowed
  double rate; // interest rate
  double mterm; // what the user will enter for monthly term 
  double yterm; // what user will enter for yearly term
  double years; // term of loan (yearly)
  double month; // term of loan (monthly)
  double sqrdMonth; // sqrt of term of loan (monthly)
  double sqrdYear; // sqrt of term of loan (yearly)
  char choice;
  }
  {
      cout &lt;&lt; "Enter your principle: " &lt;&lt; endl; // total amount borrowing
      cin &gt;&gt; prinicple;
  
      cout &lt;&lt; "Enter your your interest rate: " &lt;&lt; endl; // interest rate on loan
      cin &gt;&gt; rate;
  
      cout &lt;&lt; "Will this be (M)onthly or (Y)early payment? (enter y or m)"; // declaring if it will be a monthly or yearly payment
      cin &gt;&gt; choice;
  
      if (choice = 'M') // if its monthly 
          mterm = 12; // there are 12 months within a year
      cout &lt;&lt; "How many years will this loan be for?" &lt;&lt; endl;
      cin &gt;&gt; years; // I need this information for getting the exact
      month = mterm * years;
      sqrdMonth = sqrt(month); // I need to square root the months for the periodic payment formula
      monthlypayment = (prinicple * rate) / (rate); sqrdMonth; // this is where my problem is 
                                                  //  ^^^^ why is it asking me to close my equation with a ';'
      cout &lt;&lt; "Your monthly loan payment is: ";
      cout &lt;&lt; monthlypayment;
  
      if (choice = 'Y')
          yterm = 1;
      cout &lt;&lt; "How many years will this loan be for?" &lt;&lt; endl;
      cin &gt;&gt; years;
      years = yterm * years;
      sqrdYear = sqrt(years); // I need to square root the years for the periodic payment formula
      annualpayment = (prinicple * rate) / (rate); sqrdYear; // this is where my problem is 
                                          // ^^^^ why is it asking me to close my equation with a ';'
      cout &lt;&lt; "Your annual loan payment is: ";
      cout &lt;&lt; annualpayment;
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I expect for the user to input the principle, rate, and length of loan then the compiler to do the math and then output the correct numbers. My actual results are negative numbers or irrational numbers. </p>