static void Main(string[] args) { Interest si; Console.Write("Enter the priciple: "); double principle = double.Parse(Console.ReadLine()); Console.Write("Enter the rate: "); double rate = double.Parse(Console.ReadLine()); Console.Write("Enter the years: "); int years = int.Parse(Console.ReadLine()); Console.WriteLine("Choose the Option...\n 1.Simple Interest\t2.Coumpound Interst"); int choice = int.Parse(Console.ReadLine()); if (choice == 1) { si = new SimpleInterest(); si.CalculateInterest(principle, rate, years); } else if (choice == 2) { si = new CompoundInterest(); si.CalculateInterest(principle, rate, years); } else { Console.WriteLine("Wrong Choice"); } }
public IActionResult Index() { CompoundInterest c = new CompoundInterest(); if ( HttpContext.Request.Query["p"].Count != 0 && HttpContext.Request.Query["i"].Count != 0 && HttpContext.Request.Query["t"].Count != 0 && HttpContext.Request.Query["y"].Count != 0 ) { c.Principal = Convert.ToDouble(HttpContext.Request.Query["p"].ToString()); c.InterestRate = Convert.ToDouble(HttpContext.Request.Query["i"].ToString()); c.TimesCompounded = Convert.ToInt32(HttpContext.Request.Query["t"].ToString()); c.Years = Convert.ToInt32(HttpContext.Request.Query["y"].ToString()); } else { c.Principal = 1000; c.InterestRate = 5; c.TimesCompounded = 12; c.Years = 10; } ViewBag.Env = _env.EnvironmentName; return(View(c)); }
public void TimesCompoundedCannotBeZero() { CompoundInterest ci = new CompoundInterest(); Action act = () => ci.TimesCompounded = 0; Assert.Throws <Exception>(act); }
public void InterestRateCannotBeNegative() { CompoundInterest ci = new CompoundInterest(); Action act = () => ci.InterestRate = -10; Assert.Throws <Exception>(act); }
public void PrincipalAmountCannotBeNegative() { CompoundInterest ci = new CompoundInterest(); Action act = () => ci.Principal = -10; Assert.Throws <Exception>(act); }
/// <inheritdoc /> public async Task <Amount> CalcAmount(decimal initialValue, int months) { var compoundInterest = new CompoundInterest(); var interestRate = await GetInterestRate(); var finalValue = compoundInterest.Calculate(new Amount(initialValue), interestRate, new Months(months)); return(finalValue); }
static void Main(string[] args) { Interest interest = new SimpleInterest(); interest.CalculateInterest(1000, 5, 6); Interest interest2 = new CompoundInterest(); interest2.CalculateInterest(1111, 2, 5); }
public void CompoundInterestTest() { double amount = CompoundInterest.GetAmount(principal, rate, time); double interest = CompoundInterest.GetInterest(principal, rate, time); Assert.AreEqual(principal, CompoundInterest.GetPrincipal(amount, rate, time)); Assert.AreEqual(time, CompoundInterest.GetTime(amount, principal, rate)); Assert.AreEqual(rate, CompoundInterest.GetRate(amount, principal, time)); }
public void GivenPrincipal10ExpectAbount10() { double P = 0.0; CompoundInterest ci = new CompoundInterest(); double actual = ci.getAmount(P, 1, 1, 1); double expected = 0; Assert.Equal(expected, actual); }
public void TimesCompoundedCannotBeZero() { CompoundInterest ci = new CompoundInterest(); Exception ex = Assert.Throws <Exception>( () => ci.TimesCompounded = 0 ); Assert.Equal("Times interest is compounded per year cannot be zero.", ex.Message); }
public void PrincipalAmountCannotBeNegative() { CompoundInterest ci = new CompoundInterest(); Exception ex = Assert.Throws <Exception>( () => ci.Principal = -10 ); Assert.Equal("Principal amount cannot be negative.", ex.Message); }
public void InterestRateCannotBeNegative() { CompoundInterest ci = new CompoundInterest(); Exception ex = Assert.Throws <Exception>( () => ci.InterestRate = -10 ); Assert.Equal("Interest rate cannot be negative.", ex.Message); }
public void YearsCannotBeNegative() { CompoundInterest ci = new CompoundInterest(); Exception ex = Assert.Throws <Exception>( () => ci.Years = -10 ); Assert.Equal("Years cannot be negative.", ex.Message); }
private ValueAtMaturity GetValueAtMaturity() { var days = (MaturityDate - TradeDate).Days; var interest = CompoundInterest.CalculateInterestAmount(Amount, days, InterestRate); var taxesAmount = interest * Taxes; return(new ValueAtMaturity(Amount + interest, taxesAmount)); }
public async Task <decimal> CalculateCompoundInterest(decimal initialValue, int time, decimal interestRate) { var compoundInterest = new CompoundInterest { InitialValue = initialValue, Time = time, InterestRate = interestRate }; return(await Task.FromResult(compoundInterest.CalculateCompoundInterest(2))); }
public void GivenNagativeYearThrowException() { double t = -1.0; CompoundInterest ci = new CompoundInterest(); Exception ex = Assert.Throws <Exception>( () => ci.getAmount(1, 1, 1, t) ); string actual = ex.Message; string expected = "The number of year cannot be negative number."; Assert.Equal(expected, actual); }
public void GivenParametersExpectAmount() { double P = 5000; double r = 0.05; double n = 12.0; double t = 10.0; CompoundInterest ci = new CompoundInterest(); double actual = Math.Round(ci.getAmount(P, r, n, t), 1);// round to 2 decimal places double expected = 8235.0; Assert.Equal(expected, actual); }
public void GivenDivideNBy0ThrowException() { double n = 0.0; CompoundInterest ci = new CompoundInterest(); Exception ex = Assert.Throws <Exception>( () => ci.getAmount(1, 1, n, 1) ); string actual = ex.Message; string expected = "The number of times cannot divide by 0 time."; Assert.Equal(expected, actual); }
public void GivenNegativePrincipalThrowException() { double P = -1.0; CompoundInterest ci = new CompoundInterest(); Exception ex = Assert.Throws <Exception>( () => ci.getAmount(P, 1, 1, 1) ); string actual = ex.Message; string expected = "The principal cannot be negative number."; Assert.Equal(expected, actual); }
public void CalculateCompoundInterest_SemTruncate() { var compoundInterest = new CompoundInterest { InitialValue = 100M, InterestRate = 0.01M, Time = 5 }; var result = compoundInterest.CalculateCompoundInterest(null); Assert.Equal(105.1010050100M, result); }
public void CalculateCompoundInterest_Correto() { var compoundInterest = new CompoundInterest { InitialValue = 100M, InterestRate = 0.01M, Time = 5 }; var result = compoundInterest.CalculateCompoundInterest(2); Assert.Equal(105.1M, result); }
public ActionResult Index(CompoundInterest c) { if (ModelState.IsValid) { var result = c.CompoundInterestCalculator(); TempData["balance"] = result.ToString(); return(RedirectToAction("Index", new { p = c.Principal, i = c.InterestRate, t = c.TimesCompounded, y = c.Years })); } return(View(c)); }
public void should_return_zero_value_if_amount_is_zero() { // Arr var compoundInterest = new CompoundInterest(); var months = new Months(5); var interestRate = new InterestRate(0.01M); var amount = new Amount(0.00M); // Act var finalAmount = compoundInterest.Calculate(amount, interestRate, months); // Ass finalAmount.Value.Should().Be(0); }
public void Calculate_PrincipalAndPercentageAndYearsAndPeriods_ReturnTotalAmount() { var context = new CompoundInterestContext { Principal = 1500.00, InterestPercent = 4.3, InvestYears = 6, CompoundingFrequency = 4, }; double sum = CompoundInterest.Calculate(context); Assert.That(sum, Is.EqualTo(1938.84)); }
public void should_calculate_correctly_interest_value() { // Arr var compoundInterest = new CompoundInterest(); var months = new Months(5); var interestRate = new InterestRate(0.01M); var amount = new Amount(100.00M); // Act var finalAmount = compoundInterest.Calculate(amount, interestRate, months); // Ass finalAmount.Value.Should().Be(105.10M); }
public void P1000T12I5Y10Results1647dot01() { CompoundInterest ci = new CompoundInterest() { Principal = 1000, TimesCompounded = 12, InterestRate = 5, Years = 10 }; var expected = 1647.01; var actual = Math.Round(ci.CompoundInterestCalculator(), 2); Assert.Equal(expected, actual); }
static void Main(string[] argd) { SimpleInterest oSI = new SimpleInterest(5000, 12.5, 5); CompoundInterest oCI = new CompoundInterest(5000, 12.5, 5, 3); oSI.Calculate(); oCI.Calculate(); CompareInterest compare = new CompareInterest(); compare.Compare(oSI, oCI); Console.WriteLine(); Console.WriteLine("Press any key"); Console.ReadLine(); }
public IActionResult Index([FromQuery] string p, [FromQuery] string i, [FromQuery] string t, [FromQuery] string y, [FromQuery] string x) { CompoundInterest c = new CompoundInterest(); if (p != null && i != null && t != null && y != null ) { c.Principal = Convert.ToDouble(p); c.InterestRate = Convert.ToDouble(i); c.TimesCompounded = Convert.ToInt32(t); c.Years = Convert.ToInt32(y); } else { c.Principal = 1000; c.InterestRate = 5; c.TimesCompounded = 12; c.Years = 10; } if (string.IsNullOrEmpty(_config["REGION"])) { ViewBag.Region = "Environment variable REGION must be set to East or West."; } else { ViewBag.Region = _config["REGION"]; } if (x != null) { string strRun = x; if (strRun.ToLower() == "true" || strRun.ToLower() == "yes" || strRun.ToLower() == "1") { var result = c.CompoundInterestCalculator(); TempData["balance"] = result; } } return(View(c)); }
static void Main(string[] args) { SimpleInterest oSI = new SimpleInterest(5000, 15.5, 3); oSI.Calculate(); oSI.Display(); oSI = null; CompoundInterest oCI = new CompoundInterest(5000, 15.5, 3, 4); oCI.Calculate(); oCI.Display(); oCI.DeductServiceCharge(250); oCI.Calculate(); oCI.Display(); oCI = null; Console.WriteLine("Press a key..."); }
private void CalculateYear() { CompoundInterestItemYear.Years = CompoundInterest.CalculateYears(CompoundInterestItemYear); RaisePropertyChanged("CompoundInterestItemYear"); }