早教吧作业答案频道 -->其他-->
java复利求和的算法代码如下Scannerin=newScanner(System.in);System.out.print("Howmuchmoneydoyouneedtoretire?");doublegoal=in.nextDouble();System.out.print("Howmuchmoneywillyoucontributeeveryyear?");doublepayment=in.n
题目详情
java复利求和的算法
代码如下
Scanner in = new Scanner(System.in);
System.out.print("How much money do you need to retire?");
double goal = in.nextDouble();
System.out.print("How much money will you contribute every year?");
double payment = in.nextDouble();
System.out.print("Interest rate in %:");
double interestRate = in.nextDouble();
double balance = 0;
int years = 0;
while (balance < goal)
{
// add this year's payment and interest
balance += payment;
double interest = balance * interestRate / 100;
balance += interest;
years++;
}
下面这个while循环的原理是啥,看不懂他的原理,感觉很简洁很牛
主要请讲下设计思路
代码如下
Scanner in = new Scanner(System.in);
System.out.print("How much money do you need to retire?");
double goal = in.nextDouble();
System.out.print("How much money will you contribute every year?");
double payment = in.nextDouble();
System.out.print("Interest rate in %:");
double interestRate = in.nextDouble();
double balance = 0;
int years = 0;
while (balance < goal)
{
// add this year's payment and interest
balance += payment;
double interest = balance * interestRate / 100;
balance += interest;
years++;
}
下面这个while循环的原理是啥,看不懂他的原理,感觉很简洁很牛
主要请讲下设计思路
▼优质解答
答案和解析
这个balance不是利息,是本息和,复利就是利息不断加到本金里面利滚利
看了java复利求和的算法代码如下...的网友还看了以下:
长方形的长是A宽是B面积是S则A*B=S如果A一定那么BS成什么比例如果B一定AS成什么比例如果S一 2020-03-30 …
当把肯定句改为疑问句时,动词需要变吗?比如第三人称动词一般加"s",如果改为疑问句,还要不要"s" 2020-05-13 …
德语:词典中对名词的解释(-s,-s)分别代表什么?德语:词典中对名词的解释(-s,-s)分别代表 2020-05-17 …
sometime+s与不加s的区别?是不是以下:如果它做I的谓语,则不需加s,如果它做He的谓语, 2020-05-23 …
● In software engineering and systems engineering, 2020-05-25 …
●In software engineering and systems engineering, 2020-05-26 …
In software engineering and systems engineering,(7 2020-05-26 …
In software engineering and systems engineering, ( 2020-05-26 …
一架喷气式飞机,飞行速度是800m/s,如果它喷出的气体相对飞机的速度小于800m/s,那么以地面 2020-06-25 …
1.请画图说明数据库系统的三级模式结构.2.已知R、S如图所示,求:R∪S,R∩S,R-S,R×S 2020-07-08 …