/    Sign up×
Community /Pin to ProfileBookmark

Help with a Javascript Interest Rate Program

[code]
function calculateInterest(numberOfPounds)

{

//

};

// Insert your code here for part (iii)(a)

// Main program starts here

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)? ‘,”)

}

[/code]

I need help with making a function called ‘CalculateInterest()’ with the argument ‘numberofPounds’

I need it to make requested calculations and return answers rounded off to the nearest penny. I need an addition made so that the function is called properly.

And as you know the amount of interest is given by multiplying the amount of money by the interest rate and dividing the result by 100.

Please help.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@steveaJun 21.2007 — I get the strangest feeling that this is homework. Working off that assumption, do you have any ideas as to how to go about this? A particular question? I can't give you the answer to this with a clean conscious, though I could help point you in the right direction if you actually tried.
Copy linkTweet thisAlerts:
@viper12authorJun 21.2007 — I've got no real idea off this, primarily because I'm terrible with mathematical functions within javascript.

I'd venture as far as the following

<i>
</i>
calculateinterest =( (InterestRate) / 100 )



That's the captain obvious part, but what I don't know is how to round off a figure.
Copy linkTweet thisAlerts:
@viper12authorJun 21.2007 — Thanks for all the help guys, I can't tell you how much it means to me.

Wankers.
×

Success!

Help @viper12 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...