Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Sunday, January 15, 2023

simple interest calculation in javascript


Simple interest calculation in javascript



In this article, we are going to learn how to calculate simple interest calculation in javascript. Simple interest is a method of calculating the interest on a loan or deposit where the interest is calculated only on the original principal amount.

 
simple interest calculation in javascript


The formula for calculating simple interest is:
si=p*t*r/100



Where,
p=Principal amount
t= Time/period
r= Rate of interest.
si=Simple interest.

Source Code:


simple interest calculation in javascript

Explanation:



In above program first we declare four variables: p for principal, r for rate, t for time and si for simple interest.

Then we use the prompt() function to ask the user for the principal amount, interest rate, and time period. The prompt() function returns the user's input as a string, so the program uses parseFloat() function to convert the input to a number and stored in variables p,t, and r.


At last, the program uses the document.write() function to display the simple interest on the page.

Now the program calculates the interest using the formula,

si = p*t*r/100


Output:







Final Words:


I hope that now you have clear cut idea about how to calculate simple interest calculation in javascript. If you have any doubt please feel free to write suggestion in comment box.


You may also Read:

Introduction to OpenAI and ChatGPT

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages