/    Sign up×
Community /Pin to ProfileBookmark

need HELP….Simple Stuff

can some one work up a script for me ok Hold UP I need this in straight JAVA.

public void main…etc.. JAVA

A person invests $20,000 in a savings account yielding 5% interest.
Assuming that all the interest is left on deposit and there are no withdrawals.
Calculate and print out the amount of money in the account at the end of each year for 10 years.

Use the following formula for determining these amounts

s=p*(1+t) y

Where

P is the original amount invested (i.e. the principal capital)
t is the annual interest rate
y is the number of years
s is the total amt of money at the end of the Yth year

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayJan 26.2004 — [code=php]
for (var y=1;y<11;y++){
document.write("Year "+y+" Savings = "+(20000*(1+0.05)*y)+"<br/>");
}
[/code]
Copy linkTweet thisAlerts:
@steelersfan88Jan 26.2004 — The code would just require you to loop 10 times:

[code=php]

<form name="interest">
<textarea rows=18 cols=40 name="interest_results"></textarea><BR><BR>
<input type="button" name="results" value="Get Results!" onclick="dointerest(this.form)">
</form>

<script>

function dointerest(form) {
var p = 20000 // principle
var t = 1.05 // rate plus 1
var y = 10 // years
var s = new Array (y) // amount after each year
var results = " Results of Calculation:n ====================== nn " // results

for(var i=1;i<=y;i++) {
s[i] = eval(p * t * i)
}

for(var j=1;j<=y;j++) {
results = ""+ results +" After Year "+ j +": $"+ s[j] +"n "
}

form.interest_results.value = results
}

</script>[/code]
That will:

  • - find the value of s for each year by looping the number of years.

  • - place each one into an array of s

  • - place it into a text area


  • Hope you like it ... works just fine
    ×

    Success!

    Help @imaxx70 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.20,
    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,
    )...