Page 429 - Webapplication11_C11_Flipbook
P. 429
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>
On running the above program, we get the following output:
Practical Work 427

