A person deposits Rs 1000 in a fixed account yielding 5% interest. Compute the amount in the account at the end of each year for n years. Read n numbers. Count the number of negative numbers, positive numbers and zeros in the list in internet technologies

 <!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Investment</title>

</head>

<body>

    <p>

        <b>Lab 5</b>


    </p>

    <p>

        <table>

            <tr><td>Amount</td><td><input type="text" id="amount" value="1000"/></td></tr>

            <tr><td>Rate of Interest</td><td><input type="text" id="roi" value="5"/></td></tr>   

            <tr><td>No of Years</td><td><input type="text" id="N" value="1"/></td></tr>

            <tr><td></td><td><input type="button"  value="Compute" onclick="compute()"/></td></tr>

        </table>

    </p>

        <p id="result"></p>

        <script>

            function compute(){

                var a=Number(document.getElementById('amount').value);

                var r=Number(document.getElementById('roi').value);

                var n=Number(document.getElementById('N').value);

                var result="<table border='1'><tr><th>Years</th><th>Principal Amount</th><th>Amount</th></tr>"

                    for(var y=1;y<=n;y++){

                        var ai=a+a*r/100;

                        result=result+="<tr><td>"+y+"</td><td>"+a.toFixed(2)+"</td><td>"+ai.toFixed(2)+"</td></tr>"

                        a=ai;

                    }

                    result=result+"</table>"

                    document.getElementById("result").innerHTML=result;

            }

        </script>

</body>

</html>



Comments