i just need some help to make a java program on the following formula.
let
p=current principal
ad=annual addition
r=rate of interest
t=no of years
c=number of times to be compounded yearly
il be taking user input but for eg
let p=100
r=10%=10/100=0.1
ad=100
t=3
c=1
so for first year;
ans=p+ad*(1+r/c)^c
ans=200*1.1=220
so p for 2nd year =220
for second year
ans=p+ad*(1+r/c)^c
ans=320*1.1=352
for 3rd p=352
then for third year
ans=452*1.1
=497.2 which shld be showed as output
What I have tried:
im nt understanding how to loop this,so if someone could help it would be a great help
解决方案
Looks like a homework. What have you tried so far?
You cannot ask such questions here. You need to put some efforts in it first, try something on your own and then if you find any difficulty, post it as a question. But don't post your entire homework like this.
It's your homework, it's your responsibility to complete it. We are not here to do the homework for you. Please read Code Project Quick Answers FAQ[^] before posting question here. Don't ruin the forum this way.
Try it yourself, you may find it is not as difficult as you think!
KR
Quote:ans=p+ad*(1+r/c)^c
Quote:ans=200*1.1=220
There is a mismatch between the above formulas: one of them is incorrect.
Loops are very simple to implement. See, for instance: Loops - Learn Java - Free Interactive Java Tutorial[^].
You already have the formula in your question. Turning that into Java code is not difficult if you do some reading. See The Java™ Tutorials[^].