﻿<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title> Compute the outstanding balance on a loan </Title>
            <Description> Expansion snippet to compute the outstanding balance on a loan. </Description>
            <Author>Microsoft Corporation</Author>
            <SnippetTypes>          
                <SnippetType> Expansion </SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID> LoanAmount </ID>
                    <Default> loanAmount </Default>
                    <ToolTip> The actual loan amount taken. </ToolTip>
                </Literal>
                <Literal>
                    <ID> RateOfInterest </ID>
                    <Default> rateOfInterest </Default>
                    <ToolTip> The annual rate of interest. </ToolTip>
                </Literal>
                <Literal>
                    <ID> NumberOfMonths </ID>
                    <Default> noOfMonths </Default>
                    <ToolTip> Number of months for which loan is taken. </ToolTip>
                </Literal>
                <Literal>
                    <ID> MonthsPaymentMade </ID>
                    <Default> monthsPaymentMade </Default>
                    <ToolTip> EMI payment made for number of months. </ToolTip>
                </Literal>
            </Declarations>
            <Code Language="vjsharp" Format="CData"><![CDATA[
double annualRateofInterest;
double annualRateInMonths;
double dEMI;
double dBalance;
if (($LoanAmount$ > 0) && ($RateOfInterest$ > 0) && ($NumberOfMonths$ > 0) && ($MonthsPaymentMade$ >= 0))
{
    annualRateofInterest = $RateOfInterest$ / ( 12 * 100 ) ;
    annualRateInMonths = annualRateofInterest + 1;
    annualRateInMonths = java.lang.Math.pow(annualRateInMonths, $NumberOfMonths$);
    dEMI = (($LoanAmount$ * annualRateofInterest) * annualRateInMonths) / (annualRateInMonths - 1);
    dBalance = (dEMI * $NumberOfMonths$) - (dEMI * $MonthsPaymentMade$);
}
$selected$ $end$
]]>
</Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>
