Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
Posted
Updated 1-Jul-18 21:57pm

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
 
Share this answer
 
v2
Comments
Member 13894581 2-Jul-18 3:40am    
this is not a home work
@KrunalRohit
i was surfing on the net and came through a compound interest calculator so i wanted to make an app for the same
the logic given in the question is my work here,i m just not able to put this logic in the loop.i wanted some help thats why i posted this question here.my holidays are going on so im tring something new .if you forum cant help i have no issues.i had no intention to ask something to ruin the forum.Thank you
Mohibur Rashid 2-Jul-18 3:48am    
No one is worried about forum being ruined. But whoever is answering is actually worried about your learning. If you can't create a loop then the bigger problem is somewhere else. Even if it is not your homework, as you are claiming, you still need to put some effort. And you are trying to build something, you need to learn first. If you think you do not need to learn, then this is not the right forum for you, I am afraid.
Krunal Rohit 2-Jul-18 4:13am    
like I said, Try it yourself, you may find it is not as difficult as you think!


KR
Member 13894581 2-Jul-18 9:45am    
thank you sir,i figured out my mistake
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[^].
 
Share this answer
 
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[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900