Question: GetPayment(decimal, int, decimal) : decimal Returns the payment amount for an annuity based on periodic, fixed payments and a fixed interest rate. Parameters: rate -

GetPayment(decimal, int, decimal) : decimal
Returns the payment amount for an annuity based on periodic, fixed payments and a fixed interest rate.
Parameters:
- rate - the interest rate per period. For example, if the rate is an annual percentage rate (APR) of 10 percent and the customer makes monthly payments, the rate per period is 0.1/12, or 0.0083.
- numberOfPaymentPeriods - the total number of payment periods in the annuity. For example, if you make monthly payments on a four-year car loan, your loan has a total of 4 12 (or 48) payment periods.
- presentValue - the present value (or lump sum) that a series of payments to be paid in the future is worth now. For example, when a customer finances a car, the loan amount is the present value to the lender of the car payments the customer will make.
Exceptions:
- ArgumentOutOfRangeException - When the rate is less than 0. Message: The argument cannot be less than 0. Parameter name: "rate".
- ArgumentOutOfRangeException - When the rate is greater than 1. Message: The argument cannot be greater than 1. Parameter name: "rate".
- ArgumentOutOfRangeException - When the number of payments is less than or equal to zero. Message: The argument cannot be less than or equal to 0. Parameter name: "numberOfPaymentPeriods".
- ArgumentOutOfRangeException - When the present value is less than or equal to zero. Message: The argument cannot be less than or equal to 0. Parameter name: "presentValue".
The following is the code for calculating the payment:
CODE to CALCULATE the Payment:
decimal futureValue = 0; decimal type = 0; decimal payment = 0;
if (rate == 0) payment = presentValue / numberOfPaymentPeriods;
else payment = rate * (futureValue + presentValue * (decimal)Math.Pow((double)(1 + rate), (double)numberOfPaymentPeriods)) / (((decimal)Math.Pow((double)(1 + rate), (double)numberOfPaymentPeriods) - 1) * (1 + rate * type));
return Math.Round(payment, 2);
Sales Quote -vehicle Sale Price: decimal -tradelnAmount: decimal -sales Tax Rate : decimal -accessoriesChosen : Accessories -exteriorFinishChosen : ExteriorFinish > +VehicleSale Price : decimal > +TradeInAmount: decimal > +AccessoriesChosen : Accessories > +Exterior FinishChosen : ExteriorFinish > > +Accessory Cost: decimal > > +FinishCost: decimal > > +SubTotal: decimal > > +SalesTax : decimal > > +Total : decimal > > +AmountDue : decimal +Sales Quote(vehicleSale Price : decimal, tradelnAmount : decimal, sales TaxRate : decimal, accessoriesChosen : Accessories, exterior FinishChosen : ExteriorFinish) +Sales Quote(vehicleSale Price : decimal, tradelnAmount : decimal, sales TaxRate : decimal) > > V > ExteriorFinish > Accessories Invoice -provincialSalesTax Rate : decimal -goodsAndServices Tax Rate : decimal > + ProvincialSales Tax Rate : decimal > +GoodsAndServices Tax Rate : decimal |> > +ProvincialSalesTaxCharged: decimal > > +GoodsAndServices TaxCharged: decimal > > +SubTotal : decimal > > +Total : decimal +Invoice(provincial Sales TaxRate : decimal, goodsAndServicesTax Rate : decimal) The ProvincialSalesTaxChanged, GoodsAndServices Tax Charged, and SubTotal properties are all abstract. This diagramming tool can not represent properties as abstract. > Cost Type Labour Part Material Servicelnvoice > > +LabourCost : decimal > > +Parts Cost : decimal > > +MaterialCost : decimal > > +ProvincialSalesTaxCharged: decimal > > +GoodsAndServicesTaxCharged: decimal > > +SubTotal : decimal > > +Total : decimal +Servicelnvoice(provincialTax Rate : decimal, goodsAndServices Tax Rate : decimal) +AddCost(type: Cost Type, amount : decimal) CarWashinvoice -packageCost : decimal -fragranceCost : decimal > +PackageCost : decimal > +FragranceCost : decimal > > +ProvincialSalesTaxCharged: decimal > > +GoodsAndServicesTaxCharged: decimal > > +SubTotal : decimal > > +Total : decimal +CarWashInvoice(provincialSales TaxRate : decimal, goodsAndServices TaxRate : decimal) +CarWashInvoice provincialSales TaxRate: decimal, goodsAndService TaxRate : decimal, packageCost: decimal, fragranceCost : decimal) >
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
