Page 385 - Web Applications (803) Class 11
P. 385

28.   Write a JavaScript code to accept principle and time from the user. If time is more than 5 years then rate will be
                      10% otherwise 8%. Calculate and display simple interest.

                  Ans.  <html>
                      <body text=”blue”>

                      <script>
                      var pr=prompt(“Enter principle amount”);
                      var t=prompt(“Enter time in years”);
                      if (t>5)

                        r=10;
                      else
                        r=8;
                      var si=(pr*r*t)/100;
                      document.write(“The simple interest is”+si);

                      </script></body>
                      </html>
                      Outputs:





























                                                                                                     Practical Work  383
   380   381   382   383   384   385   386   387   388   389   390