//Calculate the amount of money you will receive based on your option
if (n == 0) {
while (death - 1 >= counter) {
System.out.format("Week %2d Linear: $%.2f Exponential: $%.2f\n", counter, a, p);
if ((death - 1 == counter) && (a >= p)) {
System.out.format("Your uncle dies in week %2d. But you were lucky and received an extra " +
"$%.2f dollars.\n", death, ((death * initial) - ((Math.pow(2, (death - 1))/100))));
}
if ((p > a) && (death - 1 >= counter)) {
System.out.format("Your uncle dies in week %2d. But you were unlucky and missed an extra " +
"$%.2f dollars.\n", death, (p - a));
}
a += initial;
counter++;
p = p * 2;
}
}
输出:停止输出处理
周1直线:$ 1.39的指数:$ 0.01
周2线性:$ 2.79的指数:$ 0.02
周3线性:$ 4.18的指数:$ 0.04
第4周线性:5.58美元指数:0.08美元
周5线性:$ 6.97的指数:$ 0.16
周6线性:$ 8.36的指数:$ 0.32
第7周线性:$ 9.76的指数:$ 0.64
第8周线性:$ 11.15指数:$ 1.28
第9周线性:$ 12.55指数:$ 2.56
第10周线性:$ 13.94指数:$ 5.12
第11周线性:$ 15.34指数:$ 10.24
第12周线性:$ 16.73指数:$ 20.48
你叔叔死在31星期,但你不走运,错过了一个额外的 $ 3.75美元。
第13周线性:$ 18.12指数:$ 40.96
你叔叔死在31星期,但你不走运,错过了一个额外的 $ 22.84美元。
第14周线性:$ 19.52指数:$ 81.92
你叔叔死在31星期,但你不走运,错过了一个额外的 $ 62.40美元。
我的问题是我该如何阻止我的if语句,以便当p> a时它将停止输出并说他已经死亡。在我的例子中的第12周,我希望它停止输出并说他死了。
它几乎如果十二点当p终于比我想提出一个更大的突破,但我真的不能把不等式说当p最终通过停止输出 – donortiz
你真的应该解决您的压痕。 – Zarwan
对不起,我刚开始使用java和这个网站.. – donortiz