-
Notifications
You must be signed in to change notification settings - Fork 0
/
loanMoney.cs
40 lines (39 loc) · 1.51 KB
/
loanMoney.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DoubleDivision
{
internal class loanMoney
{
static void MainM()
{
int months;
double enter_rate, loan;
Console.Write("Enter Money Loan=$");
loan = double.Parse(Console.ReadLine());
Console.Write("Enter inerest rate=%");
enter_rate = double.Parse(Console.ReadLine());
Console.Write("Enter month=");
months = int.Parse(Console.ReadLine());
Console.WriteLine("Month \t\tInstallment\tInterest\tDebit");
double rate = enter_rate / 100;
double installment = (loan * rate) / (1 - (Math.Pow((1 + rate), -months)));
double total_interest=0, total_installment=0;
for (int i = 1; i <= months; i++)
{
double interest = loan * rate;
double debit = loan - (installment - interest);
Console.WriteLine($"Month: {i}\t{installment:c2}\t\t{interest:c2}\t\t{debit:c2}");
loan = debit;
total_interest += interest;
total_installment += installment;
}
Console.WriteLine("========================================================");
Console.WriteLine($"Total interest: {total_interest:c2}");
Console.WriteLine($"Total instllment: {total_installment:c2}");
Console.ReadKey();
}
}
}