
07-09-2007
|
| Senior Member
Join Date: Jun 2007
Posts: 1,399
BRL$: 4,187.66 Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 172 | | Aaargh, function trouble. I am supposed to be changing the setInterestRate function so that it prompts for the current rate and this rate is then assigned to var interestRate. To confirm this, the function displayInterestRate is called and it writes the value to output window. I will need to perform some math on the the setInterestRate variable. I have highlighted the part I need help with (in red). Here is the code I've got so far: var interestRate = 0; var response; var amountIn, interest; function twoDPs(anyNumber) { return Math.round (100 * anyNumber) / 100 }; function setInterestRate(interestRate) { window.prompt('Enter the interest rate', '') // Insert your code here }; function displayInterestRate(interestRate) { document.write('Current interest rate is ' + interestRate + '%') }; function calculateInterest(numberOfPounds) { // Insert your code here }; // Insert your code here // Main program starts here setInterestRate(interestRate); displayInterestRate(interestRate); document.write('
'); // The following code may be changed response = window.prompt('Do you want to calculate the interest on an amount of money (Y/N)? ',''); while(response == 'Y') { amountInPounds = window.prompt('Enter amount in Pounds ',''); interest = calculateInterest(amountInPounds); document.write('£ '+ amountInPounds + ' attracts £' + interest + ' interest'); document.write('
'); response = window.prompt('Do you want to calculate the interest for another amount (Y/N)? ','') } To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts. | |
__________________ To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
To receive latest updates about BRL Forums, Subscribe to Latest Updates Thread.
| | | |