private double interestRate
public Mortgage(double p, double i, int t)
public string calcPayment()
m=principal*(((interestRate/12)*Math.Pow((1+(interestRate/12)),term))/(Math.Pow((1+(interestRate/12)),term)-1));
return (m).ToString("C2");
public string calcTotalCost()
m=principal*(((interestRate/12)*Math.Pow((1+(interestRate/12)),term))/(Math.Pow((1+(interestRate/12)),term)-1));
return (tc).ToString("C2");
public string calcInterest()
m=principal*(((interestRate/12)*Math.Pow((1+(interestRate/12)),term))/(Math.Pow((1+(interestRate/12)),term)-1));
return (ti).ToString("C2");
public static void Main()
Mortgage loan = new Mortgage(200000,0.05,360);
Console.WriteLine("The mortgage's principal is: " + loan.principal);
Console.WriteLine("The mortgage's payment is: " + loan.calcPayment());
Console.WriteLine("The mortgage's total cost is: " + loan.calcTotalCost());
Console.WriteLine("The mortgage's total cost is: " + loan.calcInterest());