Simple Interest Calculator - Website
Here we are going to create a calculator that calculates Simple Interest.
First We need to Go to the Design Page and design our basic calculator. Let us create a calculator which consists of three Text Boxes for adding principle in one Text Box , Rate of Interest in another and Time in another as shown below in fig2.0
FIG 2.0
Now after designing Text Boxes add Button and Labels to calculate and show result. Observe fig2.1:
FIG 2.1
As we can see from fig 2.1, I have initially created a table which can be done as follows,
Click on Layout -> Insert Table, then a window will popup as in fig 2.2
FIG 2.2
From that Insert table property dialog box add number of rows or columns as you like. Once this is done then in the table create design as in fig 2.1
Now In my case I have named the Text Boxes and Labels as TxtPrinciple for Text Box1, TxtDuration for Text Box2, TxtRate for Text Box3, LblAmountEarned for Label1, LblEndingBalance for Label2. And also the Text in the Label is made to empty " ". Button named BtnCalculate
Once this is done double click on the button we will go to aspx.cs page
We know the formula for Simple Interest is SI = (p*n*r)/100
So we take values p , n , r and SI as double
double p,n,r,SI;
After this is done we add take the input from text boxes, as we know the text entered is string we convert them to double and the code follows as below :
p = double.Parse(TxtPrinciple.Text);
n = double.Parse(TxtDuration.Text) / 365;
r = double.Parse(TxtRate.Text);
Here I am taking n - 'time' in days hence I am dividing it by 365
Now we calculate SI = (p*n*r)/100
Here we are also displaying total amount which is' double Total = SI + p;'
Now we are rounding off the decimal points to 2 places by using Math.Round(value,no of digits after decimal points) and store this in an output value.
double AmountEarned = Math.Round(SI, 2);
double EndingBalance = Math.Round(Total, 2);
Now, Finally we have to Display the output which is done as below:
LblAmountEarned.Text = AmountEarned.ToString();
LblEndingBalance.Text = EndingBalance.ToString();
Once this is done we can now run to check the output.
The entire code as shown below in fig 2.3
thanx...was looking for the same solution...helped me a lot...
ReplyDeleteMy pleasure. I will have to update more often with more solutions
Delete