ShowAll Questionssorted byDate Posted
Abhay Mohan

# Calculate SI And CI

Hi All,
I m new in lightning and try some basic .... can anyone help me out... Output is not showing properly

Component Program
=================
<aura:component >
<aura:attribute name = "Amt" type = "decimal"/>
<aura:attribute name = "ROI" type = "decimal"/>
<aura:attribute name = "Tm" type = "decimal"/>
<aura:attribute name = "Intr" type = "decimal"/>
<aura:attribute name = "Toamt" type = "decimal"/>
<lightning:card title = "Simple and Compound Interest" iconName= "standard:apps">
<aura:set attribute = "actions">
<lightning:buttonGroup>
<lightning:button label = "Simple Interest" onclick = "{!c.simpme}" variant = "success"/>
<lightning:button label = "Compound Interest" onclick = "{!c.compme}" variant = "brand"/>
</lightning:buttonGroup>
</aura:set>
<lightning:input label="Amount" value="{!v.Amt}"/>
<lightning:input label="Rate of Interest" value="{!v.ROI}"/>
<lightning:input label="Term" value="{!v.Tm}"/>
<lightning:input label="Interest Accumulated at the End of Term" value="{!v.Intr}"/>
<lightning:input label="Total Maturity Amount" value="{!v.Toamt}"/>
</lightning:card>
</aura:component>

Controller Program
===============
({
simpme : function(component, event, helper)
{
var P = component.get("v.amt");
var T = component.get("v.ROI");
var R = component.get("v.Tm");
var res = (P*T*R)/100;
component.set("v.intr", res);
var tamt = parseInt(P)+parseInt(res);
component.set("v.Toamt", tamt);
},
compme : function(component, event, helper)
{
var P = component.get("v.amt");
var T = component.get("v.ROI");
var R = component.get("v.Tm");
var res = P*(1+R/100)^T;
component.set("v.intr", res);
var tamt = parseInt(P)+parseInt(res);
component.set("v.Toamt", tamt);
}
})
Best Answer chosen by Abhay Mohan
Suraj Tripathi 47
Hi Abhay,

Please take reference from the below code:-
```<aura:component >
<aura:attribute name = "Amt" type = "decimal"/>
<aura:attribute name = "ROI" type = "decimal"/>
<aura:attribute name = "Tm" type = "decimal"/>
<aura:attribute name = "Intr" type = "decimal"/>
<aura:attribute name = "Toamt" type = "decimal"/>
<lightning:card title = "Simple and Compound Interest" iconName= "standard:apps">
<aura:set attribute = "actions">
<lightning:buttonGroup>
<lightning:button label = "Simple Interest" onclick = "{!c.simpme}" variant = "success"/>
<lightning:button label = "Compound Interest" onclick = "{!c.compme}" variant = "brand"/>
</lightning:buttonGroup>
</aura:set>
<lightning:input label="Amount" value="{!v.Amt}"/>
<lightning:input label="Rate of Interest" value="{!v.ROI}"/>
<lightning:input label="Term" value="{!v.Tm}"/>
<lightning:input label="Interest Accumulated at the End of Term" value="{!v.Intr}"/>
<lightning:input label="Total Maturity Amount" value="{!v.Toamt}"/>
</lightning:card>
</aura:component>```

```({
simpme : function(component, event, helper)
{
var P = component.get("v.Amt");
var T = component.get("v.ROI");
var R = component.get("v.Tm");
var res = (P*T*R)/100;
component.set("v.Intr", res);
var tamt = parseInt(P)+parseInt(res);
component.set("v.Toamt", tamt);
},
compme : function(component, event, helper)
{
var P = component.get("v.Amt");
var T = component.get("v.ROI");
var R = component.get("v.Tm");
var res = P*(1+R/100)^T;
component.set("v.Intr", res);
var tamt = parseInt(P)+parseInt(res);
component.set("v.Toamt", tamt);
}
})```

In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.

Suraj Tripathi 47
Hi Abhay,

Please take reference from the below code:-
```<aura:component >
<aura:attribute name = "Amt" type = "decimal"/>
<aura:attribute name = "ROI" type = "decimal"/>
<aura:attribute name = "Tm" type = "decimal"/>
<aura:attribute name = "Intr" type = "decimal"/>
<aura:attribute name = "Toamt" type = "decimal"/>
<lightning:card title = "Simple and Compound Interest" iconName= "standard:apps">
<aura:set attribute = "actions">
<lightning:buttonGroup>
<lightning:button label = "Simple Interest" onclick = "{!c.simpme}" variant = "success"/>
<lightning:button label = "Compound Interest" onclick = "{!c.compme}" variant = "brand"/>
</lightning:buttonGroup>
</aura:set>
<lightning:input label="Amount" value="{!v.Amt}"/>
<lightning:input label="Rate of Interest" value="{!v.ROI}"/>
<lightning:input label="Term" value="{!v.Tm}"/>
<lightning:input label="Interest Accumulated at the End of Term" value="{!v.Intr}"/>
<lightning:input label="Total Maturity Amount" value="{!v.Toamt}"/>
</lightning:card>
</aura:component>```

```({
simpme : function(component, event, helper)
{
var P = component.get("v.Amt");
var T = component.get("v.ROI");
var R = component.get("v.Tm");
var res = (P*T*R)/100;
component.set("v.Intr", res);
var tamt = parseInt(P)+parseInt(res);
component.set("v.Toamt", tamt);
},
compme : function(component, event, helper)
{
var P = component.get("v.Amt");
var T = component.get("v.ROI");
var R = component.get("v.Tm");
var res = P*(1+R/100)^T;
component.set("v.Intr", res);
var tamt = parseInt(P)+parseInt(res);
component.set("v.Toamt", tamt);
}
})```

In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
This was selected as the best answer
Abhay Mohan
Thank you