JavaScript Practice Questions And Answer

Problem: Write a program to find out simple interest (SI).
Solution:
    <html>
     <head>
        <title>practice 2</title> 
         <script>
            function findSI()
            {
                var p=0.0
                var r=0.0
                var t=0.0
                var box1 = document.getElementById("input1")
                p = parseFloat( box1.value )
                var box2 = document.getElementById("input2")
                r = parseFloat( box2.value )
                var box3 = document.getElementById("input3")
                t = parseFloat( box3.value )
                var si = (p * r * t) / 100
                var resultDiv = document.getElementById("result")
                resultDiv.innerHTML = "Simple Interest = " + si
            }
         </script>
     </head>
        <body>
          Enter Principal
           <input type="text" id="input1"/>  </br>
          Enter Rate
           <input type="text" id="input2"/>  </br>
          Enter Time
           <input type="text" id="input3"/>  </br>
           <input type="button" id="button1" value="Submit" onclick="findSI()"/>
           <div id="result">
          simple interest = 0
           </div>
        </body>
    </html>
          

Contact Us

Our Address

Office no.- 401,Shekhar Central Building ,Palasiya, Pin-code:452001, Indore

Email Us

contact@codebetter.in

Call Us

+91 88230 75444, +91 99939 28766

Loading
Your message has been sent. Thank you!