fbpx

Create a HTML Document with JavaScript code that has three Textboxes and a button.
The details should be accepted using textboxes are principal, rate of interest, and
duration in years. When user clicks the OK Button a message box appears showing the
simple interest of principal amount.

0
(0)

Create a HTML Document with JavaScript code that has three Textboxes and a button.
The details should be accepted using textboxes are principal, rate of interest, and
duration in years. When user clicks the OK Button a message box appears showing the
simple interest of principal amount.

<html>
  <head>
    <title>Simple Interest Calculator</title>
  </head>
  <body>
    <p>Principal: <input type="text" id="principal" /></p>
    <p>Rate of Interest: <input type="text" id="rate" /></p>
    <p>Duration (years): <input type="text" id="duration" /></p>
    <p><button onclick="calculateInterest()">OK</button></p>
    <script>
      function calculateInterest() {
        var principal = document.getElementById("principal").value;
        var rate = document.getElementById("rate").value;
        var duration = document.getElementById("duration").value;
        var interest = (principal * rate * duration) / 100;
        alert("The simple interest is: " + interest);
      }
    </script>
  </body>
</html>

Output:

Simple Interest Calculator

Principal:

Rate of Interest:

Duration (years):

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?