java 公式编码,需要帮助java编码的公式

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[^].

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值