title: Loan C# console app, interest total doesn't start at zero
body: <p>I've got this working the way it should, except the output for the first row shows the running total for interest payment as already summarized, instead the same as the first interest amount. So if the first month is 1.05 interest, running total for first month should show 1.05. Second month would be 1.05 + new interest amount. Right now it shows for example above, 2.10 as first month total.
  Where is my logic screwed?</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace Loan_Program
  {
      class Loan
      {
          //declare variables
          private double LoanAmount, InterestRate;
          private int LoanLength;
  
          //Constructor of Loan class that takes amount, rate and years
          public Loan(double amount, double rate, int years)
          {
              this.LoanAmount = amount;
              this.InterestRate = (rate / 100.0) / 12.0;
              this.LoanLength = years;
          }
          //returns the monnthly payment
          public double GetMonthlyPayment()
          {
              int months = LoanLength * 12;
              return (LoanAmount * InterestRate * Math.Pow(1 + InterestRate, months)) / (Math.Pow(1 + InterestRate, months) - 1);
          }
          //Calculates totl interterest paid and doubles it, then returns the amount
          public double TotalInterestPaid(double number1,double number2)
          {
              double TotalInterest = number1+number2;
  
              return  TotalInterest;
          }
  
  
          //prints the amortization of Loan
          public void LoanTable()
          {
              double monthlyPayment = GetMonthlyPayment();//calculates monthly payment
              double principalPaid = 0;
              double newBalance = 0;
              double interestPaid = 0;
              double principal = LoanAmount;
              double totalinterest = 0;
              //nonth, payment amount, principal paid, interest paid, total interest paid, balance
              Console.WriteLine("{0,10}{1,10}{2,10}{3,10}{4,10}{5,10}", "Payment Number", "Payment Amt", "Interest Paid", "Principal paid","Balance Due","Total Interest Paid");
              for (int month = 1; month &lt;= LoanLength * 12; month++)
              {
                  // Compute amount paid and new balance for each payment period
                  interestPaid = principal * InterestRate;
                  principalPaid = monthlyPayment - interestPaid;
                  newBalance = principal - principalPaid;
                  totalinterest += interestPaid;
                  // Output the data item              
                  Console.WriteLine("{0,-10}{1,10:N2}{2,10:N2}{3,10:N2}{4,10:N2}{5,10:N2}",
   month, monthlyPayment, interestPaid, principalPaid, newBalance, TotalInterestPaid(totalinterest,interestPaid));
                  // Update the balance
                  principal = newBalance;
              }
          }
  
      }
  }
  </code></pre>
  
  <p>Main Program</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace Loan_Program
  {
      class LoanTest
      {
          static void Main(string[] args)
          {
              //declare variables
              double amount;
              double rate;
              int years;
              //prompt loan amount
              Console.WriteLine("Enter loan amount");
              amount = Convert.ToDouble(Console.ReadLine());//accepts console input and assigne to variable
              //prompt for rate
              Console.WriteLine("Enter annual interest rate");
              rate = Convert.ToDouble(Console.ReadLine());//accepts console input and assigne to variable
              //prompt for monhts
              Console.WriteLine("Enter number of years");
              years = Convert.ToInt32(Console.ReadLine());//accepts console input and assigne to variable
  
              Loan loan = new Loan(amount, rate, years);//create  new instance, send values to the class
  
              loan.LoanTable();
  
              Console.ReadKey();
          }
      }
  }
  </code></pre>