# Calculating Interest - A program

• Jun 22, 2007, 09:58
```<HTML> <HEAD> <TITLE>Interest Rate</TITLE> <SCRIPT> var interestRate = 0; var response; var amountInPounds; var interest; function twoDPs(anyNumber) {     return Math.round (100 * anyNumber) / 100 }; function setInterestRate() {         InterestRate = parseInt(window.prompt('Please enter the rate of Interest Rate of your choosing' + ''), 10) }; function displayInterestRate() {         document.write('<BR>' + 'Current interest rate is ' + interestRate + '%')        }; function calculateInterest(numberOfPounds) { interest = numberOfPounds * interestRate / 100; interest = twoDPs(interest); // or interest = interest.toFixed(2); }; setInterestRate(); displayInterestRate(); document.write('<BR><BR><BR><BR>'); response = window.prompt('Do you want to calculate the interest on an amount of money (Y/N)? ',''); while(response == 'Y' || response == 'y') {         amountInPounds = window.prompt('Enter amount in Pounds ','');         interest = calculateInterest(amountInPounds);         document.write('£ '+ amountInPounds + ' attracts £' + interest + ' interest');         document.write('<BR><BR><BR>');          response = window.prompt('Do you want to calculate the interest for another amount (Y/N)? ','')        } </SCRIPT> </HEAD> <BODY> </BODY> </HTML>```