Dovresti fare il confronto tra i due codici in modo da capire le differenze.

ps. non dico che il codice del libro sia sbagliato, dico solo che è un po' antico e non lo conosco per niente, mentre quello che ho rifatto si ritrova comunemente oggi


codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Applicazione 15</title>
    <script language="javascript" type="text/javascript">
// <!CDATA[

function calcolate()
{
    var importo = parseFloat(document.getElementById("importo").value);
    var tasso = parseFloat(document.getElementById("tasso").value) / 100 / 12;
    var rate = parseFloat(document.getElementById("anni").value) * 12;
    var pot = Math.pow(1 + tasso, rate);
    var mese = (importo * pot * tasso) / (pot-1);
    //verifica del risultato
    if (!isNaN(mese) && (mese != Number.POSITIVE_INFINITY) && (mese != Number.NEGATIVE_INFINITY) )
    { 
        document.getElementById("rata").value = Math.round(mese);
        document.getElementById("rimborso").value = Math.round(mese * rate);
        document.getElementById("interessetotale").value = Math.round((mese * rate)- importo);
    }
    //dati non validi
    else
    {
        document.getElementById("rata").value = "";
        document.getElementById("rimborso").value = "";
        document.getElementById("interessetotale").value = "";
    }

}

function round(x)
{
    return Math.round(x *100 )/100;
}


// ]]>
    </script>

    
</head>
<body>
    <h3>calcola della rata mensile di un mutuo</h3>
    <hr/>
    <form id="modulo" action="?">
        <table>
            <tr>
                <td colspan="2">inserimento dati</td>
            </tr>
            <tr> 
                <td>importo del mutuo</td>
                <td><input type="text" id="importo" name="importo" size="13" /></td> 
            </tr>
            <tr> 
                <td>tasso annuo di interesse</td>
                <td><input type="text" id="tasso" name="tasso" size="13"/></td> 
            </tr>
            <tr> 
                <td>durata in anni del rimborso</td>
                <td><input type="text" id="anni" name="anni" size="13"/></td> 
            </tr>
            <tr>
                <td>premi il pulsante per calcolare:</td>
                <td><input type="button" value="calcola" onclick="calcolate();"/></td> 
            </tr>
            <tr>
                <td colspan="2" >informazioni sul pagamento</td> 
            </tr>
            <tr>
                <td>rata mensile:</td>
                <td><input type="text" id="rata" name="rata" size="13"/></td> 
            </tr>
            <tr>
                <td>rimborso totale:</td>
                <td><input type="text" id="rimborso" name="rimborso" size="13"/></td> 
            </tr>
            <tr>
                <td>interesse totale sul capitale:</td>
                <td><input type="text" id="interessetotale" name="interessetotale" size="13"/></td>
            </tr>
        </table>
    </form>


</body>
</html>