Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptJavaScript Program to find simple interest

JavaScript Program to find simple interest

What is ‘Simple Interest’?
Simple interest is a quick method of calculating the interest charge on a loan. Simple interest is determined by multiplying the daily interest rate by the principal by the number of days that elapse between payments.

Simple Interest formula:
 

Simple interest formula is given by: 
Simple Interest = (P x T x R)/100 
Where, 
P is the principal amount 
T is the time and 
R is the rate

Examples:

Input : P = 10000
        R = 5
        T = 5
Output :2500
We need to find simple interest on 
Rs. 10,000 at the rate of 5% for 5 
units of time.

Input : P = 3000
        R = 7
        T = 1
Output :210

The formula to calculate the simple interest is: simple_interest = (P * T * R) / 100 where P is the principal amount, T is time & R is the rate of interest. 

Implementation: Below is the implementation of above approach:

Javascript




<script>
 
    // JavaScript program to find simple interest for
    // given principal amount, time and rate of
    // interest.
 
    let P = 1, R = 1, T = 1;
 
    /* Calculate simple interest */
    let SI = (P * T * R) / 100;
 
    /* Print the resultant value of SI */
    console.log("Simple Interest = " + SI);
</script>


Output:

Simple Interest = 0.01

Time Complexity: O(1).
Auxiliary Space: O(1).

Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

RELATED ARTICLES

Most Popular

Recent Comments