Untitled

 avatar
unknown
csharp
2 years ago
970 B
21
Indexable
using System;

namespace LoanBreakdown
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the total loan amount: ");
            double loanAmount = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("What is your interest rate: ");
            double interestRate = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("What is the monthly payment: ");
            double monthlyPayment = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Month - Interest - Principle - Balance");
            for (int i = 1; i <= 10; i++)
            {
                double interest = loanAmount * interestRate / 100 / 12;
                double principle = monthlyPayment - interest;
                loanAmount -= principle;
                Console.WriteLine("{0,-6}{1,-10:C2}{2,-12:C2}{3,-14:C2}", i, interest, principle, loanAmount);
            }
        }
    }
}
Editor is loading...