In: Computer Science
Using C#
Create a class called CreditAccount. When user create this account, she/he need to enter sum of credit and loan repayment period in months. Monthly payment need to calculate using bank percentage. You must come up with a formula for calculating percentage, you can use any formula, you want.
using System;
public class CreditAccount {
// Function to calculate monthly payment
static float payment(float p,float r, float t)
{
float pay;
r = r / (12 * 100); // one month interest
t = t * 12; // one month period
pay = (p * r * (float)Math.Pow(1 + r, t))
/ (float)(Math.Pow(1 + r, t) - 1);
return (pay);
}
static public void Main ()
{
float principal, rate, time, emi;
principal = ;
rate = ;
time = ;
pay =payment(principal, rate, time);
Console.WriteLine("Monthly Payment is = " + pay);
}
}
using System;
public class CreditAccount {
// Function to calculate monthly payment
static float payment(float p,float r, float t)
{
float pay;
r = r / (12 * 100); // one month interest
t = t * 12; // one month period
pay = (p * r * (float)Math.Pow(1 + r, t))
/ (float)(Math.Pow(1 + r, t) - 1);
return (pay);
}
static public void Main ()
{
float principal, rate, time, emi;
principal = ;
rate = ;
time = ;
pay =payment(principal, rate, time);
Console.WriteLine("Monthly Payment is = " + pay);
}
}